Skip to content

Commit 62fcb1a

Browse files
committed
Clippy lint fixes
1 parent 06e799e commit 62fcb1a

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/dynamic.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,14 @@ impl BitVector for Bvd {
280280
match endianness {
281281
Endianness::Little => {
282282
for i in 0..num_bytes {
283-
buf[i] = (self.data[i / Self::BYTE_UNIT] >> ((i % Self::BYTE_UNIT) * 8) & 0xff)
283+
buf[i] = ((self.data[i / Self::BYTE_UNIT] >> ((i % Self::BYTE_UNIT) * 8)) & 0xff)
284284
as u8;
285285
}
286286
}
287287
Endianness::Big => {
288288
for i in 0..num_bytes {
289-
buf[num_bytes - i - 1] = (self.data[i / Self::BYTE_UNIT]
290-
>> ((i % Self::BYTE_UNIT) * 8)
291-
& 0xff) as u8;
289+
buf[num_bytes - i - 1] = ((self.data[i / Self::BYTE_UNIT]
290+
>> ((i % Self::BYTE_UNIT) * 8)) & 0xff) as u8;
292291
}
293292
}
294293
}
@@ -313,12 +312,12 @@ impl BitVector for Bvd {
313312
}
314313

315314
fn write<W: Write>(&self, writer: &mut W, endianness: Endianness) -> std::io::Result<()> {
316-
return writer.write_all(self.to_vec(endianness).as_slice());
315+
writer.write_all(self.to_vec(endianness).as_slice())
317316
}
318317

319318
fn get(&self, index: usize) -> Bit {
320319
debug_assert!(index < self.length);
321-
(self.data[index / Self::BIT_UNIT] >> (index % Self::BIT_UNIT) & 1).into()
320+
((self.data[index / Self::BIT_UNIT] >> (index % Self::BIT_UNIT)) & 1).into()
322321
}
323322

324323
fn set(&mut self, index: usize, bit: Bit) {
@@ -446,15 +445,15 @@ impl BitVector for Bvd {
446445
fn shl_in(&mut self, bit: Bit) -> Bit {
447446
let mut carry = bit;
448447
for i in 0..(self.length / Self::BIT_UNIT) {
449-
let b = self.data[i] >> (Self::BIT_UNIT - 1) & 1;
450-
self.data[i] = self.data[i] << 1 | carry as u64;
448+
let b = (self.data[i] >> (Self::BIT_UNIT - 1)) & 1;
449+
self.data[i] = (self.data[i] << 1) | carry as u64;
451450
carry = b.into();
452451
}
453452
if self.length % Self::BIT_UNIT != 0 {
454453
let i = self.length / Self::BIT_UNIT;
455-
let b = self.data[i] >> (self.length % Self::BIT_UNIT - 1) & 1;
454+
let b = (self.data[i] >> (self.length % Self::BIT_UNIT - 1)) & 1;
456455
self.data[i] =
457-
(self.data[i] << 1 | carry as u64) & u64::mask(self.length % Self::BIT_UNIT);
456+
((self.data[i] << 1) | carry as u64) & u64::mask(self.length % Self::BIT_UNIT);
458457
carry = b.into();
459458
}
460459
carry
@@ -465,12 +464,12 @@ impl BitVector for Bvd {
465464
if self.length % Self::BIT_UNIT != 0 {
466465
let i = self.length / Self::BIT_UNIT;
467466
let b = self.data[i] & 1;
468-
self.data[i] = self.data[i] >> 1 | (carry as u64) << (self.length % Self::BIT_UNIT - 1);
467+
self.data[i] = (self.data[i] >> 1) | ((carry as u64) << (self.length % Self::BIT_UNIT - 1));
469468
carry = b.into();
470469
}
471470
for i in (0..(self.length / Self::BIT_UNIT)).rev() {
472471
let b = self.data[i] & 1;
473-
self.data[i] = self.data[i] >> 1 | (carry as u64) << (Self::BIT_UNIT - 1);
472+
self.data[i] = (self.data[i] >> 1) | ((carry as u64) << (Self::BIT_UNIT - 1));
474473
carry = b.into();
475474
}
476475
carry
@@ -725,7 +724,7 @@ impl fmt::Octal for Bvd {
725724
while let Some(b0) = it.next() {
726725
let b1 = it.next().unwrap_or(Bit::Zero);
727726
let b2 = it.next().unwrap_or(Bit::Zero);
728-
let octet = (b2 as u8) << 2 | (b1 as u8) << 1 | b0 as u8;
727+
let octet = ((b2 as u8) << 2) | ((b1 as u8) << 1) | b0 as u8;
729728
if octet != 0 {
730729
last_nz = s.len();
731730
}

src/fixed.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ where
313313
writer: &mut W,
314314
endianness: Endianness,
315315
) -> std::io::Result<()> {
316-
return writer.write_all(self.to_vec(endianness).as_slice());
316+
writer.write_all(self.to_vec(endianness).as_slice())
317317
}
318318

319319
fn get(&self, index: usize) -> Bit {
320320
debug_assert!(index < self.length);
321-
(self.data[index / Self::BIT_UNIT] >> (index % Self::BIT_UNIT) & I::ONE).into()
321+
((self.data[index / Self::BIT_UNIT] >> (index % Self::BIT_UNIT)) & I::ONE).into()
322322
}
323323

324324
fn set(&mut self, index: usize, bit: Bit) {
@@ -448,15 +448,15 @@ where
448448
fn shl_in(&mut self, bit: Bit) -> Bit {
449449
let mut carry = bit;
450450
for i in 0..(self.length / Self::BIT_UNIT) {
451-
let b = self.data[i] >> (Self::BIT_UNIT - 1) & I::ONE;
452-
self.data[i] = self.data[i] << 1 | carry.into();
451+
let b = (self.data[i] >> (Self::BIT_UNIT - 1)) & I::ONE;
452+
self.data[i] = (self.data[i] << 1) | carry.into();
453453
carry = b.into();
454454
}
455455
if self.length % Self::BIT_UNIT != 0 {
456456
let i = self.length / Self::BIT_UNIT;
457-
let b = self.data[i] >> (self.length % Self::BIT_UNIT - 1) & I::ONE;
457+
let b = (self.data[i] >> (self.length % Self::BIT_UNIT - 1)) & I::ONE;
458458
self.data[i] =
459-
(self.data[i] << 1 | carry.into()) & I::mask(self.length % Self::BIT_UNIT);
459+
((self.data[i] << 1) | carry.into()) & I::mask(self.length % Self::BIT_UNIT);
460460
carry = b.into();
461461
}
462462
carry
@@ -467,12 +467,12 @@ where
467467
if self.length % Self::BIT_UNIT != 0 {
468468
let i = self.length / Self::BIT_UNIT;
469469
let b = self.data[i] & I::ONE;
470-
self.data[i] = self.data[i] >> 1 | I::from(carry) << (self.length % Self::BIT_UNIT - 1);
470+
self.data[i] = (self.data[i] >> 1) | (I::from(carry) << (self.length % Self::BIT_UNIT - 1));
471471
carry = b.into();
472472
}
473473
for i in (0..(self.length / Self::BIT_UNIT)).rev() {
474474
let b = self.data[i] & I::ONE;
475-
self.data[i] = self.data[i] >> 1 | I::from(carry) << (Self::BIT_UNIT - 1);
475+
self.data[i] = (self.data[i] >> 1) | (I::from(carry) << (Self::BIT_UNIT - 1));
476476
carry = b.into();
477477
}
478478
carry
@@ -725,7 +725,7 @@ impl<I: Integer, const N: usize> fmt::Octal for Bvf<I, N> {
725725
while let Some(b0) = it.next() {
726726
let b1 = it.next().unwrap_or(Bit::Zero);
727727
let b2 = it.next().unwrap_or(Bit::Zero);
728-
let octet = (b2 as u8) << 2 | (b1 as u8) << 1 | b0 as u8;
728+
let octet = ((b2 as u8) << 2) | ((b1 as u8) << 1) | b0 as u8;
729729
if octet != 0 {
730730
last_nz = s.len();
731731
}

src/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'a, B: BitVector> BitIterator<'a, B> {
1717
}
1818
}
1919

20-
impl<'a, B: BitVector> Iterator for BitIterator<'a, B> {
20+
impl<B: BitVector> Iterator for BitIterator<'_, B> {
2121
type Item = Bit;
2222

2323
fn next(&mut self) -> Option<Self::Item> {
@@ -59,7 +59,7 @@ impl<'a, B: BitVector> Iterator for BitIterator<'a, B> {
5959
}
6060
}
6161

62-
impl<'a, B: BitVector> DoubleEndedIterator for BitIterator<'a, B> {
62+
impl<B: BitVector> DoubleEndedIterator for BitIterator<'_, B> {
6363
fn next_back(&mut self) -> Option<Self::Item> {
6464
if self.range.start < self.range.end {
6565
self.range.end -= 1;

0 commit comments

Comments
 (0)