Cast

Trait Cast 

Source
pub trait Cast: Copy + Eq {
    // Required methods
    fn cast(self) -> usize;
    fn invalid() -> Self;
}
Expand description

Trait for any type that can be converted to a usize. This could actually be a hash function, but we will assume that it is fast, so I’m not calling it Hash.

Required Methods§

Source

fn cast(self) -> usize

Convert to a usize.

Source

fn invalid() -> Self

A unique invalid value for this type. If you cannot identify an invalid value, then you don’t get to use CastSet, since we would need to store an Option<T> which would probably double the size of the set.

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 Cast for u8

Source§

fn cast(self) -> usize

Source§

fn invalid() -> Self

Source§

impl Cast for u16

Source§

fn cast(self) -> usize

Source§

fn invalid() -> Self

Source§

impl Cast for u32

Source§

fn cast(self) -> usize

Source§

fn invalid() -> Self

Source§

impl Cast for u64

Source§

fn cast(self) -> usize

Source§

fn invalid() -> Self

Source§

impl Cast for usize

Source§

fn cast(self) -> usize

Source§

fn invalid() -> Self

Implementors§