@@ -2054,9 +2054,9 @@ name and a double colon. The compiler uses type inference to decide which
20542054implementation to use.
20552055
20562056~~~~
2057- trait Shape { fn new(area: float) -> Self; }
20582057# use core::float::consts::pi;
20592058# use core::float::sqrt;
2059+ trait Shape { fn new(area: float) -> Self; }
20602060struct Circle { radius: float }
20612061struct Square { length: float }
20622062
@@ -2211,11 +2211,11 @@ trait Circle : Shape { fn radius(&self) -> float; }
22112211Now, we can implement ` Circle ` on a type only if we also implement ` Shape ` .
22122212
22132213~~~~
2214+ # use core::float::consts::pi;
2215+ # use core::float::sqrt;
22142216# trait Shape { fn area(&self) -> float; }
22152217# trait Circle : Shape { fn radius(&self) -> float; }
22162218# struct Point { x: float, y: float }
2217- # use core::float::consts::pi;
2218- # use core::float::sqrt;
22192219# fn square(x: float) -> float { x * x }
22202220struct CircleStruct { center: Point, radius: float }
22212221impl Circle for CircleStruct {
@@ -2247,10 +2247,10 @@ fn radius_times_area<T: Circle>(c: T) -> float {
22472247Likewise, supertrait methods may also be called on trait objects.
22482248
22492249~~~ {.xfail-test}
2250- # trait Shape { fn area(&self) -> float; }
2251- # trait Circle : Shape { fn radius(&self) -> float; }
22522250# use core::float::consts::pi;
22532251# use core::float::sqrt;
2252+ # trait Shape { fn area(&self) -> float; }
2253+ # trait Circle : Shape { fn radius(&self) -> float; }
22542254# struct Point { x: float, y: float }
22552255# struct CircleStruct { center: Point, radius: float }
22562256# impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } }
0 commit comments