TransitionMatrix

Struct TransitionMatrix 

Source
pub struct TransitionMatrix<S: States, const NS: usize, const NE: usize>(/* private fields */);
Expand description

A matrix of state transitions.

This structure organizes transitions in a 2D matrix where:

  • Rows represent source states (indexed by state index)
  • Columns represent events (indexed by event index)
  • Each cell contains the destination state for that state-event pair

The matrix allows O(1) lookup of the next state given a current state and event.

§Type Parameters

  • S: The state type implementing States
  • NS: The number of states (rows)
  • NE: The number of events (columns)

Implementations§

Source§

impl<S: States, const NS: usize, const NE: usize> TransitionMatrix<S, NS, NE>

Source

pub const fn new(arr: [[Transition<S>; NE]; NS]) -> Self

Creates a new transition matrix from a 2D array.

§Example
use tinystate::{TransitionMatrix, Transition};

let matrix = TransitionMatrix::new([[Transition::new(MyState::A); 1]; 1]);

Trait Implementations§

Source§

impl<S: Clone + States, const NS: usize, const NE: usize> Clone for TransitionMatrix<S, NS, NE>

Source§

fn clone(&self) -> TransitionMatrix<S, NS, NE>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + States, const NS: usize, const NE: usize> Debug for TransitionMatrix<S, NS, NE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: States, const NS: usize, const NE: usize> Index<usize> for TransitionMatrix<S, NS, NE>

Source§

type Output = [Transition<S>; NE]

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<S: States, const NS: usize, const NE: usize> IndexMut<usize> for TransitionMatrix<S, NS, NE>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<S: Copy + States, const NS: usize, const NE: usize> Copy for TransitionMatrix<S, NS, NE>

Auto Trait Implementations§

§

impl<S, const NS: usize, const NE: usize> Freeze for TransitionMatrix<S, NS, NE>
where S: Freeze,

§

impl<S, const NS: usize, const NE: usize> RefUnwindSafe for TransitionMatrix<S, NS, NE>
where S: RefUnwindSafe,

§

impl<S, const NS: usize, const NE: usize> Send for TransitionMatrix<S, NS, NE>
where S: Send,

§

impl<S, const NS: usize, const NE: usize> Sync for TransitionMatrix<S, NS, NE>
where S: Sync,

§

impl<S, const NS: usize, const NE: usize> Unpin for TransitionMatrix<S, NS, NE>
where S: Unpin,

§

impl<S, const NS: usize, const NE: usize> UnwindSafe for TransitionMatrix<S, NS, NE>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.