Skip to main content

checked_subslice

Function checked_subslice 

Source
pub fn checked_subslice(
    offset: usize,
    len: usize,
    container_len: usize,
) -> Result<Range<usize>, SpanError>
Expand description

Construct a half-open subslice range after validating its bounds.

This function performs the arithmetic without indexing a slice, allowing callers to translate SpanError into a format-specific error first.

§Errors

Returns SpanError when the span overflows or exceeds container_len.