Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(unstructured): fix clippy-errors #190

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading