icu_collections::codepointtrie

Trait TrieValue

Source
pub trait TrieValue:
    Copy
    + Eq
    + PartialEq
    + AsULE
    + 'static {
    type TryFromU32Error: Display;

    // Required method
    fn try_from_u32(i: u32) -> Result<Self, Self::TryFromU32Error>;

    // Provided method
    fn to_u32(self) -> u32 { ... }
}
Expand description

A trait representing the values stored in the data array of a CodePointTrie. This trait is used as a type parameter in constructing a CodePointTrie.

Required Associated Types§

Source

type TryFromU32Error: Display

Last-resort fallback value to return if we cannot read data from the trie.

In most cases, the error value is read from the last element of the data array, this value is used for empty codepointtrie arrays Error type when converting from a u32 to this TrieValue.

Required Methods§

Source

fn try_from_u32(i: u32) -> Result<Self, Self::TryFromU32Error>

A parsing function that is primarily motivated by deserialization contexts. When the serialization type width is smaller than 32 bits, then it is expected that the call site will widen the value to a u32 first.

Provided Methods§

Source

fn to_u32(self) -> u32

A method for converting back to a u32 that can roundtrip through Self::try_from_u32(). The default implementation of this trait method panics in debug mode and returns 0 in release mode.

This method is allowed to have GIGO behavior when fed a value that has no corresponding u32 (since such values cannot be stored in the trie)

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

Source§

impl TrieValue for i8

Source§

impl TrieValue for i16

Source§

impl TrieValue for i32

Source§

impl TrieValue for u8

Source§

impl TrieValue for u16

Source§

impl TrieValue for u32

Implementors§