diff --git a/Cargo.toml b/Cargo.toml index 7ef3023..2a8d2d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rgb" version = "0.8.47" -authors = ["Kornel Lesiński "] +authors = ["Kornel Lesiński ", "James Forster "] include = ["src/**/*", "Cargo.toml", "README.md", "examples/*.rs", "LICENSE"] description = "`struct RGB/RGBA/etc.` for sharing pixels between crates + convenience methods for color manipulation.\nAllows no-copy high-level interoperability. Also adds common convenience methods and implements standard Rust traits to make `RGB`/`RGBA` pixels and slices first-class Rust objects." documentation = "https://docs.rs/rgb" diff --git a/examples/example.rs b/examples/example.rs index 74bdb5a..8c0caad 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -1,15 +1,27 @@ -use rgb::*; - +#[cfg(feature = "as-bytes")] fn main() { + use rgb::{ComponentBytes, ComponentSlice, ComponentMap}; + use rgb::Rgb; - let px = RGB{r:255_u8,g:0,b:100}; + let px = Rgb { + r: 255_u8, + g: 0, + b: 100, + }; assert_eq!([px].as_bytes()[0], 255); - let bigpx = RGB16{r:65535_u16,g:0,b:0}; + let bigpx = Rgb:: { + r: 65535_u16, + g: 0, + b: 0, + }; assert_eq!(bigpx.as_slice()[0], 65535); - let px = RGB8::new(255, 0, 255); - let inverted: RGB8 = px.map(|ch| 255 - ch); + let px = Rgb::::new(255, 0, 255); + let inverted: Rgb = px.map(|ch| 255 - ch); println!("{inverted}"); // rgb(0,255,0) } + +#[cfg(not(feature = "as-bytes"))] +fn main() {} diff --git a/examples/serde.rs b/examples/serde.rs index 308939b..3608f61 100644 --- a/examples/serde.rs +++ b/examples/serde.rs @@ -3,9 +3,9 @@ use rgb::*; // Run using: cargo run --features=serde --example serde fn main() { - let color = RGB { r: 255_u8, g: 0, b: 100 }; + let color = Rgb { r:255_u8, g:0, b:100 }; println!("{}", serde_json::to_string(&color).unwrap()); - let color: RGB8 = serde_json::from_str("{\"r\":10,\"g\":20,\"b\":30}").unwrap(); + let color: Rgb = serde_json::from_str("{\"r\":10,\"g\":20,\"b\":30}").unwrap(); println!("{}", color); }