extendr_api::prelude

Trait Index

pub trait Index:
    Seal
    + Debug
    + Not<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + AddAssign
    + SubAssign
    + Pod
    + Eq
    + Ord
    + Send
    + Sync {
    type FixedWidth: Index;
    type Signed: SignedIndex;

    // Provided methods
    fn truncate(value: usize) -> Self { ... }
    fn zx(self) -> usize { ... }
    fn canonicalize(slice: &[Self]) -> &[Self::FixedWidth] { ... }
    fn canonicalize_mut(slice: &mut [Self]) -> &mut [Self::FixedWidth] { ... }
    fn from_signed(value: Self::Signed) -> Self { ... }
    fn to_signed(self) -> Self::Signed { ... }
    fn sum_nonnegative(slice: &[Self]) -> Option<Self> { ... }
}
Expand description

Trait for unsigned integers that can be indexed with.

Always smaller than or equal to usize.

Required Associated Types§

type FixedWidth: Index

Equally-sized index type with a fixed size (no usize).

type Signed: SignedIndex

Equally-sized signed index type.

Provided Methods§

fn truncate(value: usize) -> Self

Truncate value to type Self.

fn zx(self) -> usize

Zero extend self.

fn canonicalize(slice: &[Self]) -> &[Self::FixedWidth]

Convert a reference to a slice of Self to fixed width types.

fn canonicalize_mut(slice: &mut [Self]) -> &mut [Self::FixedWidth]

Convert a mutable reference to a slice of Self to fixed width types.

fn from_signed(value: Self::Signed) -> Self

Convert a signed value to an unsigned one.

fn to_signed(self) -> Self::Signed

Convert an unsigned value to a signed one.

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

Sum 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§

§

impl Index for u32

§

impl Index for u64

§

impl Index for usize

Implementors§