Skip to content

Commit

Permalink
fix(unstructured): fix clippy-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sivizius committed Aug 22, 2024
1 parent 8fff98e commit 7bd1044
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/unstructured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,20 @@ impl<'a> Unstructured<'a> {

// We only consume as many bytes as necessary to cover the entire
// range of the byte string.
// Note: We cast to u64 so we don't overflow when checking std::u32::MAX + 4 on 32-bit archs
let len = if self.data.len() as u64 <= std::u8::MAX as u64 + 1 {
// Note: We cast to u64 so we don't overflow when checking u32::MAX + 4 on 32-bit archs
let len = if self.data.len() as u64 <= u8::MAX as u64 + 1 {
let bytes = 1;
let max_size = self.data.len() - bytes;
let (rest, for_size) = self.data.split_at(max_size);
self.data = rest;
Self::int_in_range_impl(0..=max_size as u8, for_size.iter().copied())?.0 as usize
} else if self.data.len() as u64 <= std::u16::MAX as u64 + 2 {
} else if self.data.len() as u64 <= u16::MAX as u64 + 2 {
let bytes = 2;
let max_size = self.data.len() - bytes;
let (rest, for_size) = self.data.split_at(max_size);
self.data = rest;
Self::int_in_range_impl(0..=max_size as u16, for_size.iter().copied())?.0 as usize
} else if self.data.len() as u64 <= std::u32::MAX as u64 + 4 {
} else if self.data.len() as u64 <= u32::MAX as u64 + 4 {
let bytes = 4;
let max_size = self.data.len() - bytes;
let (rest, for_size) = self.data.split_at(max_size);
Expand Down

0 comments on commit 7bd1044

Please sign in to comment.