@@ -2522,7 +2522,7 @@ fn sendable_foo(f: Box<Foo + Send>) { /* ... */ }
2522
2522
fn shareable_bar <T : Share >(b : & Bar <T > + Share ) { /* ... */ }
2523
2523
~~~
2524
2524
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
2526
2526
value ascribes to no bounds. They must be added manually if any bounds are
2527
2527
necessary for usage.
2528
2528
@@ -2579,17 +2579,18 @@ fn radius_times_area<T: Circle>(c: T) -> f64 {
2579
2579
2580
2580
Likewise, supertrait methods may also be called on trait objects.
2581
2581
2582
- ~~~ {.ignore}
2582
+ ~~~
2583
2583
use std::f64::consts::PI;
2584
2584
# trait Shape { fn area(&self) -> f64; }
2585
2585
# trait Circle : Shape { fn radius(&self) -> f64; }
2586
2586
# struct Point { x: f64, y: f64 }
2587
2587
# struct CircleStruct { center: Point, radius: f64 }
2588
2588
# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } }
2589
2589
# impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } }
2590
+ # fn square(x: f64) -> f64 { x * x }
2590
2591
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> ;
2593
2594
let nonsense = mycircle.radius() * mycircle.area();
2594
2595
~~~
2595
2596
0 commit comments