Trait Symbol

Source
pub trait Symbol:
    Copy
    + Ord
    + Eq {
    // Required methods
    fn from_usize(val: usize) -> Self;
    fn to_usize(self) -> usize;
}
Expand description

Types implementing this trait are able to act as symbols for string interners.

Symbols are returned by StringInterner::get_or_intern and allow look-ups of the original string contents with StringInterner::resolve.

§Note

Optimal symbols allow for efficient comparisons and have a small memory footprint.

Required Methods§

Source

fn from_usize(val: usize) -> Self

Creates a symbol from a usize.

§Note

Implementations panic if the operation cannot succeed.

Source

fn to_usize(self) -> usize

Returns the usize representation of self.

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 Symbol for usize

Source§

fn from_usize(val: usize) -> Self

Source§

fn to_usize(self) -> usize

Implementors§