Skip to content

Commit 58bf8b2

Browse files
committed
auto merge of #15107 : ipetkov/rust/tutorial-update, r=alexcrichton
2 parents d9611da + 39efe3c commit 58bf8b2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/doc/tutorial.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ fn sendable_foo(f: Box<Foo + Send>) { /* ... */ }
25222522
fn shareable_bar<T: Share>(b: &Bar<T> + Share) { /* ... */ }
25232523
~~~
25242524

2525-
When no colon is specified (such as the type `~Foo`), it is inferred that the
2525+
When no colon is specified (such as the type `Box<Foo>`), it is inferred that the
25262526
value ascribes to no bounds. They must be added manually if any bounds are
25272527
necessary for usage.
25282528

@@ -2579,17 +2579,18 @@ fn radius_times_area<T: Circle>(c: T) -> f64 {
25792579

25802580
Likewise, supertrait methods may also be called on trait objects.
25812581

2582-
~~~ {.ignore}
2582+
~~~
25832583
use std::f64::consts::PI;
25842584
# trait Shape { fn area(&self) -> f64; }
25852585
# trait Circle : Shape { fn radius(&self) -> f64; }
25862586
# struct Point { x: f64, y: f64 }
25872587
# struct CircleStruct { center: Point, radius: f64 }
25882588
# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } }
25892589
# impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } }
2590+
# fn square(x: f64) -> f64 { x * x }
25902591
2591-
let concrete = ~CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2592-
let mycircle: ~Circle = concrete as ~Circle;
2592+
let concrete = box CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2593+
let mycircle: Box<Circle> = concrete as Box<Circle>;
25932594
let nonsense = mycircle.radius() * mycircle.area();
25942595
~~~
25952596

0 commit comments

Comments
 (0)