Skip to main content

checked_to_usize

Function checked_to_usize 

Source
pub fn checked_to_usize(
    value: u32,
    field: &'static str,
) -> Result<usize, BinaryLayoutError>
Expand description

Converts a 32-bit offset/count value to usize with overflow checking.

ยงErrors

BinaryLayoutError::Overflow carrying field where usize is narrower than 32 bits. Unreachable on the targets this workspace builds for, and checked so that a 16-bit one would fail rather than truncate.