holochain / org

Organizational Repo for project-wide tickets
http://holochain.org
11 stars 1 forks source link

Create macro for easy reducer creation #77

Open sphinxc0re opened 6 years ago

sphinxc0re commented 6 years ago

As a Holochain-core dev I want to write reducers in a DSL-like fashion.

// TODO: write macro for DRY reducer functions
macro_rules! reducer {
    ($func_name:ident) => (
        fn reducer(old_state: Rc<$state_type>, action: &_Action) -> Rc<$state_type>  {
           // The `stringify!` macro converts an `ident` into a string.
           println!("You called {:?}()",
                   stringify!($func_name));
       }
    )
}