diff --git a/quick-rust.html b/quick-rust.html index 47dd8ea..f318fb8 100644 --- a/quick-rust.html +++ b/quick-rust.html @@ -101,7 +101,7 @@
  • Criada em 2006 por Graydon Hoare.
  • Patrocinada pela Mozilla em 2009.
  • Versão 1.0 em 2015.
  • -
  • Versão atual: 1.35
  • +
  • Versão atual: 1.35
  • Objetivo: Criar uma linguagem rápida mas com seguraça de memória.
  • @@ -141,17 +141,18 @@ Scala, Rust.

    - +
    @@ -361,7 +362,7 @@ fn is_pred(i: u64) -> Bool {
    @@ -439,6 +449,10 @@ struct MyStruct { r_a: [2u64; 10], } + +
    @@ -451,6 +465,12 @@ impl MyStruct { } } + +
    @@ -461,6 +481,16 @@ trait Summarize { fn summarize(&self) -> String; } + +
    @@ -473,6 +503,11 @@ impl Summarize for MyStruct { } } + +
    @@ -483,6 +518,18 @@ fn make_summary<T>(summarizable: T) { T.summarize() } + +
    @@ -495,6 +542,15 @@ fn make_summary<T>(summarizable: T) T.summarize() } + +
    @@ -520,6 +576,16 @@ fn may_not_exist(value: Option<String>) { ter enums com valores dentro com um enum chamado "Option"; Option tem dois valores: Some, com o valor dentro ou None, que não tem valor algum. + + E, como vimos, match tem que ser extensivo, cobrindo + todas as opções. Ou seja, não é possível não tratar + o caso do `None`. + + (É possível simplificar o match usando `if let`, que + faz pattern matching e permite acesso ao conteúdo + "embedded" dentro do bloco criado, mas é mais legal + pensar em match por causa da necessidade de ser + extensivo.) @@ -533,6 +599,13 @@ fn main() { println!("The string is: {}", a); } + +
    @@ -558,6 +631,11 @@ fn main() { println!("The string is: {}", a); } + +
    @@ -605,6 +683,15 @@ fn main() { a = 5; } + +
    @@ -620,6 +707,17 @@ enum Result<T, E> { Err(E), } + +
    @@ -629,6 +727,17 @@ match File::create("something.txt") { Err(err) => println!("Failure! {}", err), } + +
    @@ -733,6 +842,22 @@ fn main() {
    4.5k issues no Github + +