Skip to content

Commit

Permalink
Makes clippym happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dzamlo committed Jul 28, 2023
1 parent 7de0e73 commit 3787205
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ macro_rules! impl_bitrange_for_u {
impl BitRange<$bitrange_ty> for $t {
#[inline]
#[allow(clippy::cast_lossless)]
#[allow(clippy::manual_bits)]
fn bit_range(&self, msb: usize, lsb: usize) -> $bitrange_ty {
let bit_len = size_of::<$t>()*8;
let result_bit_len = size_of::<$bitrange_ty>()*8;
Expand All @@ -652,6 +653,7 @@ macro_rules! impl_bitrange_for_u {
impl BitRangeMut<$bitrange_ty> for $t {
#[inline]
#[allow(clippy::cast_lossless)]
#[allow(clippy::manual_bits)]
fn set_bit_range(&mut self, msb: usize, lsb: usize, value: $bitrange_ty) {
let bit_len = size_of::<$t>()*8;
let mask: $t = !(0 as $t)
Expand Down
12 changes: 6 additions & 6 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,35 @@ fn test_single_bit() {
assert_eq!(0x1, fb.0);
assert_eq!(0x1, fb.foo1());
assert_eq!(0x0, fb.foo2());
assert_eq!(false, fb.single_bit());
assert!(!fb.single_bit());
assert_eq!(-1, fb.signed_single_bit());

fb.set_foo2(1);
assert_eq!(0x8000_0001, fb.0);
assert_eq!(0x1, fb.foo1());
assert_eq!(0x1, fb.foo2());
assert_eq!(false, fb.single_bit());
assert!(!fb.single_bit());
assert_eq!(-1, fb.signed_single_bit());

fb.set_foo1(0);
assert_eq!(0x8000_0000, fb.0);
assert_eq!(0x0, fb.foo1());
assert_eq!(0x1, fb.foo2());
assert_eq!(false, fb.single_bit());
assert!(!fb.single_bit());
assert_eq!(0, fb.signed_single_bit());

fb.set_single_bit(true);
assert_eq!(0x8000_0008, fb.0);
assert_eq!(0x0, fb.foo1());
assert_eq!(0x1, fb.foo2());
assert_eq!(true, fb.single_bit());
assert!(fb.single_bit());
assert_eq!(0, fb.signed_single_bit());

fb.set_signed_single_bit(-1);
assert_eq!(0x8000_0009, fb.0);
assert_eq!(0x1, fb.foo1());
assert_eq!(0x1, fb.foo2());
assert_eq!(true, fb.single_bit());
assert!(fb.single_bit());
assert_eq!(-1, fb.signed_single_bit());
}

Expand Down Expand Up @@ -939,7 +939,7 @@ mod test_no_default_bitrange {
let mut bf = BitField1(0);
assert_eq!(bf.field1(), 10 + 0);
assert_eq!(bf.field2(), 12 + 3);
assert_eq!(bf.field3(), true);
assert!(bf.field3());
bf.set_field1(42);
assert_eq!(bf, BitField1(10 + 0 + 42));
}
Expand Down

0 comments on commit 3787205

Please sign in to comment.