Skip to content

Instantly share code, notes, and snippets.

macro_rules! variant_enum {
(
$variant:ident {
$(
$( #[ $oemval:meta ] )*
$oldvariant:ident => $newvariant:ident
),*
}
) => {
enum $variant {
macro_rules! variant_enums {
(
{ $( $variant:ident ),* } {
$(
$( #[ $oemval:meta ] )*
$oldvariant:ident => $newvariant:ident
),*
}
) => {
$(
macro_rules! mass_assign {
(
( $( $elm:ident ),* );
$tree:expr
) => {
$( let $elm = $tree; ),*
};
}
/// In this framework, state machines expose decision points which abstract
/// over their nonterminal states as well as exit points which abstract over
/// their terminal states. At a terminal state, only a transition to an
/// entirely new state is possible. However, at a decision point, the parent
/// state machine can either decide to step the state machine as normal, or
/// cause a transition to an entirely new state machine, which abandons the
/// original child. The parent can also decide to cause a transition to an
/// exit point, which necessarily causes the child state machine to halt and
/// be dropped.
///
[rustc]
mismatched types
expected trait std::ops::FnMut, found closure
note: expected type `(dyn for<'r> std::ops::FnMut(&'r I) -> A + 'k)`
found type `[closure@automata_impl/src/dual_state_machine.rs:47:9: 53:10 state_fn_part:_, internal_part:_]`
macro_rules! jump_table_copy {
(
$name:ident {
$( $variant:ident ) ,*
}
) => {
use std::marker::{Copy};
impl Copy for $name {}
impl Clone for $name {
macro_rules! self_match {
($token:ident) => {
( & $token, & $token )
};
}
macro_rules! jump_table_copy {
(
$name:ident : $fntype:ty {
$( $variant:ident ) ,*
macro_rules! self_match {
($token:ident) => {
( & $token, & $token )
}
}
macro_rules! jump_table_impl {
(
$name:ident : $fntype:ty {
$( $variant:ident = $value:expr ) ,*
use std::ops::FnOnce;
use automaton::Automaton;
use std::marker::PhantomData;
use std::mem::swap;
/// State machine implemented through a boxed consumable closure struct. Each
/// step, the currently boxed closure is called, returning an action and a
/// new boxed closure to call the next step.
pub struct OwnStateMachine<I, A, C: FnOnce(&I) -> (A, Box<C>)> {
current_state: Option<Box<C>>,
pub mod automaton;
pub mod state_machine;
pub mod move_state_machine;
#[cfg(test)]
mod tests {
use automaton::Automaton;
#[test]
fn fnmut_automaton_test() {