[−][src]Function dither::color::palette::parse
pub fn parse<T: FromIterator<RGB<u8>>>(s: &str) -> Result<T, Error>
parse a palette, specified as 6-digit hexidecimal RGB values (w/ optional 0x prefix) separated by newlines.
lines consisting entirely of whitespace or starting with //
are ignored.
/// don't forget to include at least two colors (probably including one of WHITE (0xffffff) or BLACK(0xffffff))
let input = " // BLACK 0x000000 // whitespace lines are ignored \t\t\t \t\t\t\t // RED 0xFF0000 // GREEN 00ff00 "; let want_colors: HashSet<_> = vec![RGB(0, 0, 0), RGB(0xff, 0x00, 0x00), RGB(0x00, 0xff, 0x00)].into_iter().collect(); assert_eq!(want_colors, palette::parse(input).unwrap());