css-named-colors 1.0.1

CSS Named Colors
Documentation
  • Coverage
  • 5.1%
    8 out of 157 items documented0 out of 7 items with examples
  • Size
  • Source code size: 46.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.99 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • swizzard/css-named-colors
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • swizzard

CSS Named Colors

Basically what it says on the tin. Conversion to/from names, hex codes, and rgb triples.
No dependencies, no allocations, mostly const.

// parsing
let color = NamedColor::from_name("rebeccapurple").expect("invalid name");
// conversion
assert_eq!("#663399", &color.hex());
assert_eq!(Some((102, 51, 153)), &color.rgb());

// `transparent` is handled reasonably
assert_eq!("transparent", NamedColor::TRANSPARENT.hex());
assert!(NamedColor::TRANSPARENT.rgb().is_none());

// aliases/collisions are handled alphabetically
assert_eq!(NamedColor::AQUA.hex(), NamedColor::CYAN.hex());
assert_eq!(NamedColor::from_hex("#00ffff").unwrap(), NamedColor::AQUA); // _not_ CYAN