Trait icu_collections::codepointtrie::cptrie::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)

Object Safety§

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§