Trait ToOffset

Source
pub trait ToOffset: PartialOrd {
    // Required method
    fn to_offset(self, length: usize) -> usize;
}
Expand description

Trait to allow the main signed and unsigned integer types where negative values are treated as offsets from the end, defined by length -1 == length -1, 0 == start, 1 == second position If the offset underflows, it returns 0. If it overflows, it returns the last index for arrays or the length for integer types.

Required Methods§

Source

fn to_offset(self, length: usize) -> usize

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToOffset for i32

Source§

fn to_offset(self, length: usize) -> usize

Source§

impl ToOffset for i64

Source§

fn to_offset(self, length: usize) -> usize

Source§

impl ToOffset for u8

Source§

fn to_offset(self, length: usize) -> usize

Source§

impl ToOffset for u16

Source§

fn to_offset(self, length: usize) -> usize

Source§

impl ToOffset for u32

Source§

fn to_offset(self, length: usize) -> usize

Source§

impl ToOffset for u64

Source§

fn to_offset(self, length: usize) -> usize

Source§

impl ToOffset for usize

Source§

fn to_offset(self, length: usize) -> usize

Implementors§