Key

Trait Key 

Source
pub trait Key: Copy + Eq {
    // Required methods
    fn try_from_usize(index: usize) -> Option<Self>;
    fn into_usize(self) -> usize;
}
Expand description

Types implementing this trait can be used as keys in the Interner.

Required Methods§

Source

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

Try to create a key from the provided usize. The first usize passed to this method will be 0; the second 1; and so on.

This method is more or less the same as the well-known TryFrom<usize> trait. We use a custom trait so that consumers don’t have to implement the well-known trait.

Source

fn into_usize(self) -> usize

Convert the key into a usize.

This method is more or less the same as the well-known Into<usize> trait. We use a custom trait so that consumers don’t have to implement the well-known trait.

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 Key for NonZeroU32

Implementors§