markovian 0.2.1

Simulation of Markov Processes as stochastic processes.
Documentation
use crate::errors::InvalidState;

/// Possible public state.
/// 
/// `State` should be implemented when it is absolutely clear what a `state` for your your struct means.
pub trait State {
    type Item: core::fmt::Debug;

    #[inline]
    fn state(&self) -> Option<&Self::Item> {
        None
    }

    #[inline]
    fn state_mut(&mut self) -> Option<&mut Self::Item> {
        None
    }

    /// # Remarks
    ///
    /// You might want to use [core::mem::swap](https://doc.rust-lang.org/core/mem/fn.swap.html).
    #[inline]
    fn set_state(
        &mut self,
        new_state: Self::Item,
    ) -> Result<Option<Self::Item>, InvalidState<Self::Item>> {
        Err(InvalidState::new(new_state))
    }
}