Skip to content

Commit

Permalink
change iterator type to slice::IterMut
Browse files Browse the repository at this point in the history
  • Loading branch information
hellow554 committed Feb 15, 2022
1 parent b442f69 commit f041379
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,8 @@ impl Blinkt {
}

/// Returns a mutable iterator over all `Pixel`s stored in `Blinkt`.
pub fn iter_mut(&mut self) -> IterMut<'_> {
IterMut {
iter_mut: self.pixels.iter_mut(),
}
pub fn iter_mut(&mut self) -> slice::IterMut<'_, Pixel> {
self.pixels.iter_mut()
}

/// Sets the red, green and blue values for a single pixel in the local
Expand Down Expand Up @@ -482,22 +480,9 @@ impl Drop for Blinkt {
}
}

/// A mutable iterator over all `Pixel`s stored in `Blinkt`.
pub struct IterMut<'a> {
iter_mut: slice::IterMut<'a, Pixel>,
}

impl<'a> Iterator for IterMut<'a> {
type Item = &'a mut Pixel;

fn next(&mut self) -> Option<Self::Item> {
self.iter_mut.next()
}
}

impl<'a> IntoIterator for &'a mut Blinkt {
type Item = &'a mut Pixel;
type IntoIter = IterMut<'a>;
type IntoIter = slice::IterMut<'a, Pixel>;

fn into_iter(self) -> Self::IntoIter {
self.iter_mut()
Expand Down

0 comments on commit f041379

Please sign in to comment.