Skip to content

Commit

Permalink
clippy (#1739)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Apr 25, 2024
1 parent f1cb334 commit 1ce0fad
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions src/bits/complete.rs
Expand Up @@ -42,41 +42,39 @@ where
move |(input, bit_offset): (I, usize)| {
if count == 0 {
Ok(((input, bit_offset), 0u8.into()))
} else if input.input_len() * 8 < count + bit_offset {
Err(Err::Error(E::from_error_kind(
(input, bit_offset),
ErrorKind::Eof,
)))
} else {
if input.input_len() * 8 < count + bit_offset {
Err(Err::Error(E::from_error_kind(
(input, bit_offset),
ErrorKind::Eof,
)))
} else {
let cnt = (count + bit_offset).div(8);
let mut acc: O = 0_u8.into();
let mut offset: usize = bit_offset;
let mut remaining: usize = count;
let mut end_offset: usize = 0;

for byte in input.iter_elements().take(cnt + 1) {
if remaining == 0 {
break;
}
let val: O = if offset == 0 {
byte.into()
} else {
((byte << offset) >> offset).into()
};

if remaining < 8 - offset {
acc += val >> (8 - offset - remaining);
end_offset = remaining + offset;
break;
} else {
acc += val << (remaining - (8 - offset));
remaining -= 8 - offset;
offset = 0;
}
let cnt = (count + bit_offset).div(8);
let mut acc: O = 0_u8.into();
let mut offset: usize = bit_offset;
let mut remaining: usize = count;
let mut end_offset: usize = 0;

for byte in input.iter_elements().take(cnt + 1) {
if remaining == 0 {
break;
}
let val: O = if offset == 0 {
byte.into()
} else {
((byte << offset) >> offset).into()
};

if remaining < 8 - offset {
acc += val >> (8 - offset - remaining);
end_offset = remaining + offset;
break;
} else {
acc += val << (remaining - (8 - offset));
remaining -= 8 - offset;
offset = 0;
}
Ok(((input.take_from(cnt), end_offset), acc))
}
Ok(((input.take_from(cnt), end_offset), acc))
}
}
}
Expand Down

0 comments on commit 1ce0fad

Please sign in to comment.