@@ -224,7 +224,7 @@ The following is an example of declaring `Shape` to be a supertrait of `Circle`.
224
224
225
225
``` rust
226
226
trait Shape { fn area (& self ) -> f64 ; }
227
- trait Circle : Shape { fn radius (& self ) -> f64 ; }
227
+ trait Circle : Shape { fn radius (& self ) -> f64 ; }
228
228
```
229
229
230
230
And the following is the same example, except using [ where clauses] .
@@ -244,7 +244,7 @@ trait Circle where Self: Shape {
244
244
// A = pi * r^2
245
245
// so algebraically,
246
246
// r = sqrt(A / pi)
247
- (self . area () / std :: f64 :: consts :: PI ). sqrt ()
247
+ (self . area () / std :: f64 :: consts :: PI ). sqrt ()
248
248
}
249
249
}
250
250
```
@@ -253,7 +253,7 @@ This next example calls a supertrait method on a generic parameter.
253
253
254
254
``` rust
255
255
# trait Shape { fn area (& self ) -> f64 ; }
256
- # trait Circle : Shape { fn radius (& self ) -> f64 ; }
256
+ # trait Circle : Shape { fn radius (& self ) -> f64 ; }
257
257
fn print_area_and_radius <C : Circle >(c : C ) {
258
258
// Here we call the area method from the supertrait `Shape` of `Circle`.
259
259
println! (" Area: {}" , c . area ());
@@ -265,7 +265,7 @@ Similarly, here is an example of calling supertrait methods on trait objects.
265
265
266
266
``` rust
267
267
# trait Shape { fn area (& self ) -> f64 ; }
268
- # trait Circle : Shape { fn radius (& self ) -> f64 ; }
268
+ # trait Circle : Shape { fn radius (& self ) -> f64 ; }
269
269
# struct UnitCircle ;
270
270
# impl Shape for UnitCircle { fn area (& self ) -> f64 { std :: f64 :: consts :: PI } }
271
271
# impl Circle for UnitCircle { fn radius (& self ) -> f64 { 1.0 } }
0 commit comments