Support web notation for hex colors

This commit is contained in:
Robert Günzler 2017-06-12 12:16:57 +02:00 committed by Joe Wilm
parent fc658b31d7
commit 68cca6eb38
1 changed files with 5 additions and 2 deletions

View File

@ -965,8 +965,11 @@ impl FromStr for Rgb {
}
}
if chars.next().unwrap() != '0' { return Err(()); }
if chars.next().unwrap() != 'x' { return Err(()); }
match chars.next().unwrap() {
'0' => if chars.next().unwrap() != 'x' { return Err(()); },
'#' => (),
_ => return Err(()),
}
component!(r, g, b);