From 089b0404293c3b71387cf355c0483251635a1996 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 10 Apr 2025 13:00:25 +0200 Subject: [PATCH] traits.md: remove unusual formatting --- src/items/traits.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/items/traits.md b/src/items/traits.md index 76d438296..30151f5c0 100644 --- a/src/items/traits.md +++ b/src/items/traits.md @@ -224,7 +224,7 @@ The following is an example of declaring `Shape` to be a supertrait of `Circle`. ```rust trait Shape { fn area(&self) -> f64; } -trait Circle : Shape { fn radius(&self) -> f64; } +trait Circle: Shape { fn radius(&self) -> f64; } ``` And the following is the same example, except using [where clauses]. @@ -244,7 +244,7 @@ trait Circle where Self: Shape { // A = pi * r^2 // so algebraically, // r = sqrt(A / pi) - (self.area() /std::f64::consts::PI).sqrt() + (self.area() / std::f64::consts::PI).sqrt() } } ``` @@ -253,7 +253,7 @@ This next example calls a supertrait method on a generic parameter. ```rust # trait Shape { fn area(&self) -> f64; } -# trait Circle : Shape { fn radius(&self) -> f64; } +# trait Circle: Shape { fn radius(&self) -> f64; } fn print_area_and_radius(c: C) { // Here we call the area method from the supertrait `Shape` of `Circle`. println!("Area: {}", c.area()); @@ -265,7 +265,7 @@ Similarly, here is an example of calling supertrait methods on trait objects. ```rust # trait Shape { fn area(&self) -> f64; } -# trait Circle : Shape { fn radius(&self) -> f64; } +# trait Circle: Shape { fn radius(&self) -> f64; } # struct UnitCircle; # impl Shape for UnitCircle { fn area(&self) -> f64 { std::f64::consts::PI } } # impl Circle for UnitCircle { fn radius(&self) -> f64 { 1.0 } }