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.
+ +
fn is_pred(i: u64) -> Bool {
@@ -370,7 +370,7 @@ fn is_pred(i: u64) -> Bool {
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.
enum IPAddr {
@@ -423,6 +425,79 @@ match home {
+struct MyStruct {
+ a_field: String,
+ r_a: [2; 10u64],
+}
+
+
+impl MyStruct {
+ fn first_element(&self) -> u64 {
+ self.r_a.get(1)
+ }
+}
+
+
+trait Summarize {
+ fn summarize(&self) -> String;
+}
+
+
+impl Summarize for MyStruct {
+ fn summarize(&self) -> String {
+ self.a_field
+ }
+}
+
+
+fn make_summary<T>(summarizable: T) {
+ T.summarize()
+}
+
+
+fn make_summary<T>(summarizable: T)
+ where T: Summarize
+{
+ T.summarize()
+}
+
+
-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")