This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! variant_enum { | |
( | |
$variant:ident { | |
$( | |
$( #[ $oemval:meta ] )* | |
$oldvariant:ident => $newvariant:ident | |
),* | |
} | |
) => { | |
enum $variant { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! variant_enums { | |
( | |
{ $( $variant:ident ),* } { | |
$( | |
$( #[ $oemval:meta ] )* | |
$oldvariant:ident => $newvariant:ident | |
),* | |
} | |
) => { | |
$( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! mass_assign { | |
( | |
( $( $elm:ident ),* ); | |
$tree:expr | |
) => { | |
$( let $elm = $tree; ),* | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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. | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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:_]` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! jump_table_copy { | |
( | |
$name:ident { | |
$( $variant:ident ) ,* | |
} | |
) => { | |
use std::marker::{Copy}; | |
impl Copy for $name {} | |
impl Clone for $name { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! self_match { | |
($token:ident) => { | |
( & $token, & $token ) | |
}; | |
} | |
macro_rules! jump_table_copy { | |
( | |
$name:ident : $fntype:ty { | |
$( $variant:ident ) ,* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! self_match { | |
($token:ident) => { | |
( & $token, & $token ) | |
} | |
} | |
macro_rules! jump_table_impl { | |
( | |
$name:ident : $fntype:ty { | |
$( $variant:ident = $value:expr ) ,* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod automaton; | |
pub mod state_machine; | |
pub mod move_state_machine; | |
#[cfg(test)] | |
mod tests { | |
use automaton::Automaton; | |
#[test] | |
fn fnmut_automaton_test() { |