SmallChar

Trait SmallChar 

Source
pub trait SmallChar:
    Copy
    + Default
    + Ord
    + Eq
    + Hash
    + Debug {
    const ZERO: Self;

    // Required methods
    fn from_char(c: char) -> Option<Self>;
    fn to_char(self) -> char;
}
Expand description

Trait for character types that can be stored in SmallString.

This trait abstracts over different character representations:

  • u16: UTF-16 code unit (2 bytes), compatible with ITensors.jl’s SmallString
  • char: Full Unicode code point (4 bytes), supports all Unicode characters

Default is u16 for memory efficiency and ITensors.jl compatibility.

Required Associated Constants§

Source

const ZERO: Self

The null/zero value for this character type.

Required Methods§

Source

fn from_char(c: char) -> Option<Self>

Convert from a Rust char. Returns None if the character cannot be represented in this type.

Source

fn to_char(self) -> char

Convert to a Rust char.

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 SmallChar for char

Source§

const ZERO: Self = '\0'

Source§

fn from_char(c: char) -> Option<Self>

Source§

fn to_char(self) -> char

Source§

impl SmallChar for u16

Source§

const ZERO: Self = 0

Source§

fn from_char(c: char) -> Option<Self>

Source§

fn to_char(self) -> char

Implementors§