From 8c3c0df4a5904aaf5d7072ca14ea6e9dd7fb326c Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Sun, 29 Dec 2024 07:53:38 +0200 Subject: fix clippy::precedence and remove usless bitmasking --- src/color.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/color.rs b/src/color.rs index 45dc5b2..0d83a85 100644 --- a/src/color.rs +++ b/src/color.rs @@ -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) } } @@ -40,9 +40,9 @@ impl FromStr for Color { fn from_str(color: &str) -> Result { 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(|_| ())?, -- cgit v1.3.1