Skip to content

Commit 2a08291

Browse files
Merge pull request #4 from smart-leds-rs/generify
Make SmartLedsWrite more generic
2 parents ee43509 + b9392f9 commit 2a08291

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "smart-leds-trait"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
authors = ["David Sawatzke <[email protected]>"]
55
edition = "2018"
66
categories = [
@@ -13,6 +13,5 @@ license = "MIT OR Apache-2.0"
1313
readme = "README.md"
1414
repository = "https://github.com/smart-leds-rs/smart-leds-trait"
1515

16-
1716
[dependencies]
1817
rgb = "0.8"

src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#![no_std]
22

3-
pub type Color = rgb::RGB8;
3+
pub use {rgb::RGB, rgb::RGB16, rgb::RGB8, rgb::RGBA};
4+
5+
pub struct White<C>(pub C);
6+
7+
pub type RGBW<ComponentType, WhiteComponentType = ComponentType> =
8+
RGBA<ComponentType, White<WhiteComponentType>>;
49

510
pub trait SmartLedsWrite {
611
type Error;
7-
fn write<T>(&mut self, iterator: T) -> Result<(), Self::Error>
12+
type Color;
13+
fn write<T, I>(&mut self, iterator: T) -> Result<(), Self::Error>
814
where
9-
T: Iterator<Item = Color>;
15+
T: Iterator<Item = I>,
16+
I: Into<Self::Color>;
1017
}

0 commit comments

Comments
 (0)