Skip to content

Commit

Permalink
fix clippy::precedence and remove usless bitmasking
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Dec 29, 2024
1 parent 1d7308d commit 8c3c0df
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ impl Color {
}

pub fn from_rgba_hex(hex: u32) -> Self {
let r = (hex >> 24 & 0xFF) as u8;
let g = (hex >> 16 & 0xFF) as u8;
let b = (hex >> 8 & 0xFF) as u8;
let a = (hex & 0xFF) as u8;
let r = (hex >> 24) as u8;
let g = (hex >> 16) as u8;
let b = (hex >> 8) as u8;
let a = hex as u8;
Self::from_rgba(r, g, b, a)
}
}
Expand All @@ -40,9 +40,9 @@ impl FromStr for Color {
fn from_str(color: &str) -> Result<Self, Self::Err> {
let rgb = color.get(1..7).ok_or(())?;
let rgb = u32::from_str_radix(rgb, 16).map_err(|_| ())?;
let r = (rgb >> 16 & 0xFF) as u8;
let g = (rgb >> 8 & 0xFF) as u8;
let b = (rgb & 0xFF) as u8;
let r = (rgb >> 16) as u8;
let g = (rgb >> 8) as u8;
let b = rgb as u8;

let a = match color.get(7..9) {
Some(a) => u8::from_str_radix(a, 16).map_err(|_| ())?,
Expand Down

0 comments on commit 8c3c0df

Please sign in to comment.