Trait SignedIndex

Source
pub trait SignedIndex:
    Seal
    + Debug
    + Neg<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + AddAssign
    + SubAssign
    + Pod
    + Eq
    + Ord
    + Send
    + Sync {
    const MAX: Self;

    // Required methods
    fn truncate(value: usize) -> Self;
    fn zx(self) -> usize;
    fn sx(self) -> usize;

    // Provided method
    fn sum_nonnegative(slice: &[Self]) -> Option<Self> { ... }
}
Expand description

Trait for signed integers corresponding to the ones satisfying Index.

Always smaller than or equal to isize.

Required Associated Constants§

Source

const MAX: Self

Maximum representable value.

Required Methods§

Source

fn truncate(value: usize) -> Self

Truncate value to type Self.

Source

fn zx(self) -> usize

Zero extend self.

Source

fn sx(self) -> usize

Sign extend self.

Provided Methods§

Source

fn sum_nonnegative(slice: &[Self]) -> Option<Self>

Sum nonnegative values while checking for overflow.

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 SignedIndex for i32

Source§

const MAX: i32 = 2_147_483_647i32

Source§

fn truncate(value: usize) -> i32

Source§

fn zx(self) -> usize

Source§

fn sx(self) -> usize

Source§

impl SignedIndex for i64

Source§

const MAX: i64 = 9_223_372_036_854_775_807i64

Source§

fn truncate(value: usize) -> i64

Source§

fn zx(self) -> usize

Source§

fn sx(self) -> usize

Source§

impl SignedIndex for isize

Source§

const MAX: isize = 9_223_372_036_854_775_807isize

Source§

fn truncate(value: usize) -> isize

Source§

fn zx(self) -> usize

Source§

fn sx(self) -> usize

Implementors§