Open
Description
I found out that field len of Element have usize type actually. But it is tested against i32. Same for pos field.
#[derive(Copy, Clone, Debug)]
struct Element {
pos: u64,
len: usize,
}
impl Element {
const EMPTY: Self = Self { pos: 0, len: 0 };
const HEADER_LENGTH: usize = 4;
#[inline]
fn new(pos: u64, len: usize) -> Result<Self> {
ensure!(i64::try_from(pos).is_ok(), CorruptedFileSnafu { //Why u64 testing against i64?
msg: "element position must be less or equal to i64::MAX"
});
ensure!(i32::try_from(len).is_ok(), ElementTooBigSnafu); //Why usize testing against i32?
Ok(Self { pos, len })
}
}
Metadata
Metadata
Assignees
Labels
No labels