diff options
| author | bors <bors@rust-lang.org> | 2014-06-24 10:16:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-24 10:16:49 +0000 |
| commit | 58bf8b2155dc2ece0cee2bc2f60c72ea60d75af3 (patch) | |
| tree | bd757057bb214b16de594e235cd16d93dc2641b7 /src/doc | |
| parent | d9611da4e652ab9428a864368c99d6e9ed3d72df (diff) | |
| parent | 39efe3c82b75b47817772ab98dd7778a3d1e5562 (diff) | |
| download | rust-58bf8b2155dc2ece0cee2bc2f60c72ea60d75af3.tar.gz rust-58bf8b2155dc2ece0cee2bc2f60c72ea60d75af3.zip | |
auto merge of #15107 : ipetkov/rust/tutorial-update, r=alexcrichton
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/tutorial.md | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index e6d9cef7a31..67a153a6584 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2522,7 +2522,7 @@ fn sendable_foo(f: Box<Foo + Send>) { /* ... */ } fn shareable_bar<T: Share>(b: &Bar<T> + Share) { /* ... */ } ~~~ -When no colon is specified (such as the type `~Foo`), it is inferred that the +When no colon is specified (such as the type `Box<Foo>`), it is inferred that the value ascribes to no bounds. They must be added manually if any bounds are necessary for usage. @@ -2579,7 +2579,7 @@ fn radius_times_area<T: Circle>(c: T) -> f64 { Likewise, supertrait methods may also be called on trait objects. -~~~ {.ignore} +~~~ use std::f64::consts::PI; # trait Shape { fn area(&self) -> f64; } # trait Circle : Shape { fn radius(&self) -> f64; } @@ -2587,9 +2587,10 @@ use std::f64::consts::PI; # struct CircleStruct { center: Point, radius: f64 } # impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } } # impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } } +# fn square(x: f64) -> f64 { x * x } -let concrete = ~CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0}; -let mycircle: ~Circle = concrete as ~Circle; +let concrete = box CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0}; +let mycircle: Box<Circle> = concrete as Box<Circle>; let nonsense = mycircle.radius() * mycircle.area(); ~~~ |
