Skip to main content

StringIndex

Trait StringIndex 

Source
pub trait StringIndex:
    Sealed
    + Copy
    + Eq
    + Ord
    + Debug
    + Display
    + Send
    + Sync
    + 'static {
    const TYPE_NAME: &'static str;

    // Required methods
    fn try_from_usize(value: usize) -> Option<Self>;
    fn to_usize(self) -> usize;
}
Expand description

Contract for integer types used by crate::StringId.

Self::try_from_usize is used at build and validation boundaries where counts are computed as usize. Self::to_usize is used on lookup paths for infallible indexing.

This trait is sealed and only implemented for unsigned integers that fit in usize on the current target.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

Human-readable type name.

Required Methods§

Source

fn try_from_usize(value: usize) -> Option<Self>

Converts a string index into this type.

Source

fn to_usize(self) -> usize

Converts this index to 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 StringIndex for u8

Source§

const TYPE_NAME: &'static str = "u8"

Source§

fn try_from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

impl StringIndex for u16

Source§

const TYPE_NAME: &'static str = "u16"

Source§

fn try_from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

impl StringIndex for u32

Source§

const TYPE_NAME: &'static str = "u32"

Source§

fn try_from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

impl StringIndex for u64

Source§

const TYPE_NAME: &'static str = "u64"

Source§

fn try_from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

impl StringIndex for usize

Source§

const TYPE_NAME: &'static str = "usize"

Source§

fn try_from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Implementors§