From db2c9e19755c2589495f5460df7f75e454684428 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Fri, 16 Jun 2023 16:38:27 -0300 Subject: [PATCH] Mais ajustes --- porque-rust.html | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/porque-rust.html b/porque-rust.html index 2de1e42..aa23575 100644 --- a/porque-rust.html +++ b/porque-rust.html @@ -251,7 +251,7 @@ let a = String::from("hello");

 fn main() {
     let a = String::from("hello");
-    let _b = a;
+    let b = a;
     println!("{}", a)
 }
                     
@@ -262,8 +262,8 @@ fn main() { error[E0382]: borrow of moved value: `a` --> src/main.rs:5:20 | -4 | let _b = a; - | - value moved here +4 | let b = a; + | - value moved here 5 | println!("{}", a) | ^ value borrowed here after move | @@ -274,9 +274,9 @@ error[E0382]: borrow of moved value: `a` @@ -293,7 +293,7 @@ error[E0382]: borrow of moved value: `a`

 fn main() {
     let a = String::from("hello");
-    let _b = &a;
+    let b = &a;
     println!("{}", a)
 }
                     
@@ -335,14 +335,6 @@ fn main() { -
-

Drop

- -

-pub fn drop<T>(_x: T) { }
-                    
-
-

Regras do Borrow Checker

@@ -466,13 +458,13 @@ pub fn drop<T>(_x: T) { }

A Linguagem Mais Amada

- - A linguagem mais amada segundo o StackOverflow - Survey 2022 + + A linguagem mais amada (admirada) segundo o + StackOverflow Survey 2023

-

... pelo 7⁰ ano seguido.

+

... pelo 8⁰ ano seguido.

-

-match File::create("something.txt") {
-    Ok(fp) => fp.write_all(b"Hello world"),
-    Err(err) => println!("Failure! {}", err),
-}
+                    

+FILE* fp = fopen("something.txt");
+fprintf(fp, "Hello world");
                     

 match File::create("something.txt") {
-    Ok(fp) => match fp.write_all(b"Hello world") {
-        Ok(_) => (),
-        Err(err) => println!("Can't write! {}", err),
-    }
+    Ok(fp) => fp.write_all(b"Hello world"),
     Err(err) => println!("Failure! {}", err),
 }