Merge branch 'refactor/review-comments-from-rust-wroclaw' into 'develop'

Refactor/review comments from rust wroclaw

See merge request mchodzikiewicz/embedded-plots!15
This commit is contained in:
Michał Chodzikiewicz 2021-03-05 23:04:26 +00:00
commit fa2ebe0ecc
2 changed files with 9 additions and 18 deletions

View file

@ -9,7 +9,7 @@ homepage = "https://gitlab.com/mchodzikiewicz/embedded-plots"
repository = "https://gitlab.com/mchodzikiewicz/embedded-plots" repository = "https://gitlab.com/mchodzikiewicz/embedded-plots"
readme = "README.md" readme = "README.md"
keywords = ["embedded", "plot", "graphics"] keywords = ["embedded", "plot", "graphics"]
categories = ["embedded","visualization"] categories = ["embedded","visualization","no-std","graphics"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -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);
}
}