Some checks failed
Continuous integration / Tests (push) Blocked by required conditions
Continuous integration / Tests (windows-latest) (push) Waiting to run
Continuous integration / Check clippy, formatting, and documentation (push) Failing after 20s
Continuous integration / Tests (ubuntu-latest) (push) Failing after 22s
Continuous integration / Check fuzzers (push) Failing after 18s
Continuous integration / Check mininum Rust version (push) Failing after 20s
28 lines
557 B
Rust
28 lines
557 B
Rust
#[cfg(feature = "as-bytes")]
|
|
fn main() {
|
|
use rgb::{ComponentBytes, ComponentSlice, ComponentMap};
|
|
use rgb::Rgb;
|
|
|
|
let px = Rgb {
|
|
r: 255_u8,
|
|
g: 0,
|
|
b: 100,
|
|
};
|
|
assert_eq!([px].as_bytes()[0], 255);
|
|
|
|
let bigpx = Rgb::<u16> {
|
|
r: 65535_u16,
|
|
g: 0,
|
|
b: 0,
|
|
};
|
|
assert_eq!(bigpx.as_slice()[0], 65535);
|
|
|
|
let px = Rgb::<u8>::new(255, 0, 255);
|
|
let inverted: Rgb<u8> = px.map(|ch| 255 - ch);
|
|
|
|
println!("{inverted}"); // rgb(0,255,0)
|
|
}
|
|
|
|
#[cfg(not(feature = "as-bytes"))]
|
|
fn main() {}
|