mirror of
https://gitlab.com/feliix42/embedded-plots.git
synced 2024-11-22 09:56:31 +00:00
Substitute curve's mutable elements with .tuple_windows(), remove dummy tests
This commit is contained in:
parent
59835f881d
commit
cbc0083fb4
1 changed files with 8 additions and 17 deletions
21
src/curve.rs
21
src/curve.rs
|
@ -102,7 +102,7 @@ impl<C, I> DrawableCurve<C, I>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// set curve line thickness
|
/// set curve line thickness
|
||||||
pub fn set_thickness(mut self, thickness: usize) -> DrawableCurve<C,I> {
|
pub fn set_thickness(mut self, thickness: usize) -> DrawableCurve<C, I> {
|
||||||
self.thickness = Some(thickness);
|
self.thickness = Some(thickness);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -123,22 +123,13 @@ impl<C, I> Drawable<C> for DrawableCurve<C, I>
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
};
|
};
|
||||||
let style = PrimitiveStyle::with_stroke(color, thickness as u32);
|
let style = PrimitiveStyle::with_stroke(color, thickness as u32);
|
||||||
let mut iter = self.scaled_data.into_iter();
|
self.scaled_data
|
||||||
let mut prev = iter.next().unwrap();
|
.tuple_windows()
|
||||||
for point in iter {
|
.try_for_each(|(prev, point)| -> Result<(), D::Error> {
|
||||||
Line::new(prev, point)
|
Line::new(prev, point)
|
||||||
.into_styled(style)
|
.into_styled(style)
|
||||||
.draw(display)?;
|
.draw(display)
|
||||||
prev = point;
|
})
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
assert_eq!(2 + 2, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue