try_wrap

Function try_wrap 

Source
pub fn try_wrap<I>(
    idx: I,
    size: usize,
    kind: IndexKind,
    wrap_scalar: bool,
) -> Result<usize, BoundsError>
where I: AsIndex,
Expand description

Wraps an index with negative indexing support.

§Arguments

  • idx - The index to canonicalize.
  • size - The size of the index range.
  • kind - The kind of index (for error messages).
  • size_name - The name of the size (for error messages).
  • wrap_scalar - If true, treat 0-size ranges as having size 1.

§Returns

A Result<usize, BoundsError> of the canonicalized index.