-
+
+ Structs Genéricas
+
+struct Point<T> {
+ x: T,
+ y: T
+}
+
+
+
+
+ Structs Genéricas
+
+
+let my_point = Point(x: 1.0, y: 2.0);
+
+
+ Enums Generics
+
enum Result<T, E> {
Ok(T),
@@ -816,6 +835,8 @@ enum Result<T, E> {
+ Traits
+
trait Summary {
fn summarize(&self) -> String;
@@ -834,7 +855,7 @@ impl Summary for Phrase {
self.phrase
.split_whitespace()
.map(|word| word.chars().nth(0).unwrap())
- .collect();
+ .collect()
}
}
@@ -846,40 +867,6 @@ fn get_summary<T>(summarizable: T) -> String
where T: Summary
{
...
-}
-
-
-
-
- Structs genéricas
-
-
-struct Point<T> {
- x: T,
- y: T
-}
-
-
-
-
-