From f753ea4abbe47c4c64916fdf0a47d51f0f684aea Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Tue, 2 Jul 2019 12:24:22 -0300 Subject: [PATCH] A few more technical bits --- quick-rust.html | 133 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 104 insertions(+), 29 deletions(-) diff --git a/quick-rust.html b/quick-rust.html index b0348a4..6c302d3 100644 --- a/quick-rust.html +++ b/quick-rust.html @@ -122,25 +122,23 @@ -

- Basic - (com números e estruturado) - , dBase III Plus - , Clipper - , Pascal - , Cobol - , Delphi (ObjectPascal) - , C - , C++ - , ActionScript (Flash) - , PHP - , JavaScript - , Python - , Objective-C - , Clojure - , Java - , Scala - , Rust. +

+ Basic (com números e estruturado), + dBase III Plus, + Clipper, + Pascal, + Cobol, + Delphi (ObjectPascal), + C, + C++, + ActionScript (Flash), + PHP, + JavaScript, + Python, + Objective-C, + Clojure, + Java, + Scala, Rust.

+ +
-

Mas De Volta ao Rust

+

De Volta ao Rust - Returns are not necessary


 fn is_pred(i: u64) -> Bool {
@@ -370,7 +370,7 @@ fn is_pred(i: u64) -> Bool {
                     
-

Mas De Volta ao Rust

+

De Volta ao Rust - Returns are not necessary


 fn is_pred(i: u64) -> Bool {
@@ -382,9 +382,11 @@ fn is_pred(i: u64) -> Bool {
                             Uma forma mais simples de escrever a função anterior.
                         
                     
+
+
-

Mas De Volta ao Rust

+

De Volta ao Rust - Enums


 enum IPAddr {
@@ -423,6 +425,79 @@ match home {
                     
+
+
+

De Volta ao Rust - No OO

+
+ +
+

No OO

+ +

+struct MyStruct {
+    a_field: String,
+    r_a: [2; 10u64],
+}
+                        
+
+ +
+

No OO - But "functions in structs"

+ +

+impl MyStruct {
+    fn first_element(&self) -> u64 {
+        self.r_a.get(1)
+    }
+}
+                        
+
+ +
+

No OO - But Traits

+ +

+trait Summarize {
+    fn summarize(&self) -> String;
+}
+                        
+
+ +
+

No OO - But Traits

+ +

+impl Summarize for MyStruct {
+    fn summarize(&self) -> String {
+        self.a_field
+    }
+}
+                        
+
+ +
+

No OO - But Generics

+ +

+fn make_summary<T>(summarizable: T) {
+    T.summarize()
+}
+                        
+
+ +
+

No OO - But Generic Traits

+ +

+fn make_summary<T>(summarizable: T)
+    where T: Summarize
+{
+    T.summarize()
+}
+                        
+
+
+

E Aquela "Segurança de Memória"?

@@ -432,7 +507,7 @@ match home {

1. No Null Pointers


-match may_not_exist(value: Option<String>) {
+fn may_not_exist(value: Option<String>) {
     match value {
         Some(the_string) => println!("I got a string! {}", the_string),
         None => println!("I got nothing")