Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Oct 3, 2022
1 parent 8372467 commit 670050f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ impl Color {
};

pub fn hex(hex: &str) -> Result<Color, String> {
if hex.len() == 9 && hex.starts_with("#") {
if hex.len() == 9 && hex.starts_with('#') {
// #FFFFFFFF (Red Green Blue Alpha)
Ok(Color {
r: map_err(u8::from_str_radix(&hex[1..3], 16))? as f32 / 255.0,
g: map_err(u8::from_str_radix(&hex[3..5], 16))? as f32 / 255.0,
b: map_err(u8::from_str_radix(&hex[5..7], 16))? as f32 / 255.0,
a: map_err(u8::from_str_radix(&hex[7..9], 16))? as f32 / 255.0,
})
} else if hex.len() == 7 && hex.starts_with("#") {
} else if hex.len() == 7 && hex.starts_with('#') {
// #FFFFFF (Red Green Blue)
Ok(Color {
r: map_err(u8::from_str_radix(&hex[1..3], 16))? as f32 / 255.0,
Expand Down

0 comments on commit 670050f

Please sign in to comment.