From cbc0083fb47e748c74b4694d7d2183abbccc39a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Chodzikiewicz?= Date: Thu, 4 Mar 2021 11:29:27 +0100 Subject: [PATCH] Substitute curve's mutable elements with .tuple_windows(), remove dummy tests --- src/curve.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/curve.rs b/src/curve.rs index 0c0a736..00e5eb6 100644 --- a/src/curve.rs +++ b/src/curve.rs @@ -102,7 +102,7 @@ impl DrawableCurve } /// set curve line thickness - pub fn set_thickness(mut self, thickness: usize) -> DrawableCurve { + pub fn set_thickness(mut self, thickness: usize) -> DrawableCurve { self.thickness = Some(thickness); self } @@ -123,22 +123,13 @@ impl Drawable for DrawableCurve Some(t) => t, }; let style = PrimitiveStyle::with_stroke(color, thickness as u32); - let mut iter = self.scaled_data.into_iter(); - let mut prev = iter.next().unwrap(); - for point in iter { - Line::new(prev, point) - .into_styled(style) - .draw(display)?; - prev = point; - } - Ok(()) + self.scaled_data + .tuple_windows() + .try_for_each(|(prev, point)| -> Result<(), D::Error> { + Line::new(prev, point) + .into_styled(style) + .draw(display) + }) } } -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -}