Trait narrow::offset::OffsetElement

source ·
pub trait OffsetElement: FixedSize + AddAssign + Default + TryFrom<usize, Error = TryFromIntError> + TryInto<usize, Error = TryFromIntError> + Sub<Output = Self> + Sealed + 'static {
    type Unsigned: TryFrom<usize, Error = TryFromIntError>;

    // Required methods
    fn checked_add(self, rhs: Self) -> Option<Self>;
    fn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self>;
}
Expand description

Types representing offset values.

Values with these types can be used to represent offset values.

This trait is sealed to prevent downstream implementations.

Required Associated Types§

source

type Unsigned: TryFrom<usize, Error = TryFromIntError>

The unsigned variant of Self.

Required Methods§

source

fn checked_add(self, rhs: Self) -> Option<Self>

Checked addition. Computes self + rhs, returning None if overflow occurred.

source

fn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self>

Checked addition with an unsigned value. Computes self + rhs, returning None if overflow occurred.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl OffsetElement for i32

§

type Unsigned = u32

source§

fn checked_add(self, rhs: Self) -> Option<Self>

source§

fn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self>

source§

impl OffsetElement for i64

§

type Unsigned = u64

source§

fn checked_add(self, rhs: Self) -> Option<Self>

source§

fn checked_add_unsigned(self, rhs: Self::Unsigned) -> Option<Self>

Implementors§