From 39e4f4c61afb8935ce3a8ebacab8202fe0a539aa Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 9 Sep 2019 20:52:51 -0400 Subject: Clippy. --- src/setup.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/setup.rs') diff --git a/src/setup.rs b/src/setup.rs index 1451cb6..614c304 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -13,7 +13,7 @@ use core::convert::{TryFrom, TryInto}; #[repr(C)] pub struct RequestType(u8); impl RequestType { - pub fn recipient(&self) -> Result { + pub fn recipient(self) -> Result { const POS: u8 = 0; const MASK: u8 = 0x1f; (self.0 & (MASK << POS)).try_into() @@ -26,7 +26,7 @@ impl RequestType { self.0 |= v as u8 & MASK; } - pub fn kind(&self) -> Result { + pub fn kind(self) -> Result { const POS: u8 = 5; const MASK: u8 = 0x3; (self.0 & (MASK << POS)).try_into() @@ -39,7 +39,7 @@ impl RequestType { self.0 |= v as u8 & MASK; } - pub fn direction(&self) -> Result { + pub fn direction(self) -> Result { const POS: u8 = 7; const MASK: u8 = 0x1; (self.0 & (MASK << POS)).try_into() @@ -119,7 +119,7 @@ impl TryFrom for RequestRecipient { #[repr(C)] pub struct WValue(u16); impl WValue { - pub fn w_value_lo(&self) -> u8 { + pub fn w_value_lo(self) -> u8 { const POS: u8 = 0; const MASK: u16 = 0xff; ((self.0 >> POS) & MASK) as u8 @@ -128,11 +128,11 @@ impl WValue { pub fn set_w_value_lo(&mut self, v: u8) { const POS: u8 = 0; const MASK: u8 = 0xff; - self.0 &= !((MASK as u16) << POS); - self.0 |= ((v & MASK) as u16) << POS; + self.0 &= !(u16::from(MASK) << POS); + self.0 |= u16::from(v & MASK) << POS; } - pub fn w_value_hi(&self) -> u8 { + pub fn w_value_hi(self) -> u8 { const POS: u8 = 8; const MASK: u16 = 0xff; ((self.0 >> POS) & MASK) as u8 @@ -141,8 +141,8 @@ impl WValue { pub fn set_w_value_hi(&mut self, v: u8) { const POS: u8 = 8; const MASK: u8 = 0xff; - self.0 &= !((MASK as u16) << POS); - self.0 |= ((v & MASK) as u16) << POS; + self.0 &= !(u16::from(MASK) << POS); + self.0 |= u16::from(v & MASK) << POS; } } impl From<(u8, u8)> for WValue { -- cgit v1.2.3