Struct StateID
struct StateID(_)
The identifier of a finite automaton state.
It is represented by a u32 even on 64-bit systems in order to conserve
space. Namely, on all targets, this type guarantees that its value will
fit in a u32, i32, usize and an isize. This means that on 16-bit
targets, for example, this type's maximum value will never overflow an
isize, which means it will never overflow a i16 even though its
internal representation is still a u32.
Safety
While a StateID is meant to guarantee that its value fits into usize
without using as much space as a usize on all targets, callers must
not rely on this property for safety. Callers may choose to rely on this
property for correctness however. For example, creating a StateID with an
invalid value can be done in entirely safe code. This may in turn result in
panics or silent logical errors.
Implementations
impl StateID
fn new(value: usize) -> Result<StateID, StateIDError>Create a new value that is represented by a "small index."
If the given index exceeds the maximum allowed value, then this returns an error.
const fn new_unchecked(value: usize) -> StateIDCreate a new value without checking whether the given argument exceeds the maximum.
Using this routine with an invalid value will result in unspecified behavior, but not undefined behavior. In particular, an invalid ID value is likely to cause panics or possibly even silent logical errors.
Callers must never rely on this type to be within a certain range for memory safety.
const fn from_u32_unchecked(index: u32) -> StateIDCreate a new value from a
u32without checking whether the given value exceeds the maximum.Using this routine with an invalid value will result in unspecified behavior, but not undefined behavior. In particular, an invalid ID value is likely to cause panics or possibly even silent logical errors.
Callers must never rely on this type to be within a certain range for memory safety.
fn must(value: usize) -> StateIDLike
new, but panics if the given value is not valid.const fn as_usize(self: &Self) -> usizeReturn the internal value as a
usize. This is guaranteed to never overflowusize.const fn as_u64(self: &Self) -> u64Return the internal value as a
u64. This is guaranteed to never overflow.const fn as_u32(self: &Self) -> u32Return the internal value as a
u32. This is guaranteed to never overflowu32.const fn as_i32(self: &Self) -> i32Return the internal value as a
i32. This is guaranteed to never overflow ani32.fn one_more(self: &Self) -> usizeReturns one more than this value as a usize.
Since values represented by a "small index" have constraints on their maximum value, adding
1to it will always fit in ausize,u32and ai32.fn from_ne_bytes(bytes: [u8; 4]) -> Result<StateID, StateIDError>Decode this value from the bytes given using the native endian byte order for the current target.
If the decoded integer is not representable as a small index for the current target, then this returns an error.
fn from_ne_bytes_unchecked(bytes: [u8; 4]) -> StateIDDecode this value from the bytes given using the native endian byte order for the current target.
This is analogous to
new_uncheckedin that is does not check whether the decoded integer is representable as a small index.fn to_ne_bytes(self: &Self) -> [u8; 4]Return the underlying integer as raw bytes in native endian format.
impl Clone for StateID
fn clone(self: &Self) -> StateID
impl Copy for StateID
impl Debug for StateID
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Default for StateID
fn default() -> StateID
impl Eq for StateID
impl Freeze for StateID
impl From for StateID
fn from(value: u8) -> StateID
impl Hash for StateID
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl Ord for StateID
fn cmp(self: &Self, other: &StateID) -> Ordering
impl PartialEq for StateID
fn eq(self: &Self, other: &StateID) -> bool
impl PartialOrd for StateID
fn partial_cmp(self: &Self, other: &StateID) -> Option<Ordering>
impl RefUnwindSafe for StateID
impl Send for StateID
impl StructuralPartialEq for StateID
impl Sync for StateID
impl TryFrom for StateID
fn try_from(value: u16) -> Result<StateID, StateIDError>
impl TryFrom for StateID
fn try_from(value: u32) -> Result<StateID, StateIDError>
impl TryFrom for StateID
fn try_from(value: u64) -> Result<StateID, StateIDError>
impl TryFrom for StateID
fn try_from(value: usize) -> Result<StateID, StateIDError>
impl Unpin for StateID
impl UnsafeUnpin for StateID
impl UnwindSafe for StateID
impl<T> Any for StateID
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for StateID
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for StateID
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for StateID
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for StateID
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for StateID
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for StateID
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for StateID
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for StateID
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>