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.

Object Safety§

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§