From ec01563bd6b94d4451508da7cbfa1298e6abb14c Mon Sep 17 00:00:00 2001 From: upsidedwn Date: Thu, 26 Jan 2023 16:59:13 +0800 Subject: [PATCH] Propose to use the generic term perimeter instead of circumference for shapes (#281) * Update unit tests to use generic perimeter * Update solution to use perimeter Update solution to use the generic term perimeter instead of circumference --- src/exercises/day-2/points-polygons.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/exercises/day-2/points-polygons.rs b/src/exercises/day-2/points-polygons.rs index 0d7c1d23..9ebfe99b 100644 --- a/src/exercises/day-2/points-polygons.rs +++ b/src/exercises/day-2/points-polygons.rs @@ -142,7 +142,7 @@ impl From for Shape { } impl Shape { - pub fn circumference(&self) -> f64 { + pub fn perimeter(&self) -> f64 { match self { Shape::Polygon(poly) => poly.length(), Shape::Circle(circle) => circle.circumference(), @@ -204,7 +204,7 @@ mod tests { } #[test] - fn test_shape_circumferences() { + fn test_shape_perimeters() { let mut poly = Polygon::new(); poly.add_point(Point::new(12, 13)); poly.add_point(Point::new(17, 11)); @@ -213,12 +213,12 @@ mod tests { Shape::from(poly), Shape::from(Circle::new(Point::new(10, 20), 5)), ]; - let circumferences = shapes + let perimeters = shapes .iter() - .map(Shape::circumference) + .map(Shape::perimeter) .map(round_two_digits) .collect::>(); - assert_eq!(circumferences, vec![15.48, 31.42]); + assert_eq!(perimeters, vec![15.48, 31.42]); } } // ANCHOR_END: unit-tests