[][src]Trait aho_corasick::StateID

pub trait StateID: Sealed + Clone + Copy + Debug + Eq + Hash + PartialEq + PartialOrd + Ord {
    fn from_usize(n: usize) -> Self;
fn to_usize(self) -> usize;
fn max_id() -> usize; }

A trait describing the representation of an automaton's state identifier.

The purpose of this trait is to safely express both the possible state identifier representations that can be used in an automaton and to convert between state identifier representations and types that can be used to efficiently index memory (such as usize).

In general, one should not need to implement this trait explicitly. Indeed, for now, this trait is sealed such that it cannot be implemented by any other type. In particular, this crate provides implementations for u8, u16, u32, u64 and usize. (u32 and u64 are only provided for targets that can represent all corresponding values in a usize.)

Required methods

fn from_usize(n: usize) -> Self

Convert from a usize to this implementation's representation.

Implementors may assume that n <= Self::max_id. That is, implementors do not need to check whether n can fit inside this implementation's representation.

fn to_usize(self) -> usize

Convert this implementation's representation to a usize.

Implementors must not return a usize value greater than Self::max_id and must not permit overflow when converting between the implementor's representation and usize. In general, the preferred way for implementors to achieve this is to simply not provide implementations of StateID that cannot fit into the target platform's usize.

fn max_id() -> usize

Return the maximum state identifier supported by this representation.

Implementors must return a correct bound. Doing otherwise may result in unspecified behavior (but will not violate memory safety).

Loading content...

Implementations on Foreign Types

impl StateID for usize[src]

impl StateID for u8[src]

impl StateID for u16[src]

impl StateID for u32[src]

impl StateID for u64[src]

Loading content...

Implementors

Loading content...