Skip to content

Commit

Permalink
Merge pull request #82 from DavJCosby/proc-macros
Browse files Browse the repository at this point in the history
exposed .leds() in driver, pass by reference instead of clone
  • Loading branch information
DavJCosby authored Sep 28, 2024
2 parents b59922c + e4f200a commit 88841ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/driver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
color::{Rgb, Srgb},
Sled, SledError, Vec2,
Led, Sled, SledError, Vec2,
};

use std::time::{Duration, Instant};
Expand Down Expand Up @@ -118,7 +118,15 @@ impl Driver {
self.sled.take().unwrap()
}

pub fn colors(&self) -> impl Iterator<Item = Rgb> + '_ {
pub fn leds(&self) -> impl Iterator<Item = &Led> {
if let Some(sled) = &self.sled {
sled.leds()
} else {
panic!("Driver has no Sled assigned!")
}
}

pub fn colors(&self) -> impl Iterator<Item = &Rgb> + '_ {
if let Some(sled) = &self.sled {
sled.colors()
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/sled/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ impl Sled {
/// /*- snip -*/
/// }
/// ```
pub fn colors(&self) -> impl Iterator<Item = Rgb> + '_ {
self.leds.iter().map(|led| led.color)
pub fn colors(&self) -> impl Iterator<Item = &Rgb> + '_ {
self.leds.iter().map(|led| &led.color)
}

/// Returns an Iterator over the RGB colors for each [LED](Led) in the system.
Expand Down

0 comments on commit 88841ce

Please sign in to comment.