macro_rules! def_nat2_callback {
($name:ident -> $ret:ty $body:block) => { ... };
($name:ident { $($field:ident : $fty:ty),* $(,)? } -> $ret:ty { |$s:ident| $($body:tt)* }) => { ... };
}Expand description
Define a Nat2Callback struct with minimal boilerplate.
Two forms:
Stateless:
use const_reify::{def_nat2_callback, nat_reify::reify_nat2};
def_nat2_callback!(Add -> u64 { A + B });
assert_eq!(reify_nat2(5, 3, &Add), 8);With fields:
use const_reify::{def_nat2_callback, nat_reify::reify_nat2};
def_nat2_callback!(ScaledSum { scale: u64 } -> u64 { |s| (A + B) * s.scale });
assert_eq!(reify_nat2(5, 3, &ScaledSum { scale: 10 }), 80);A and B refer to the two const-generic u64 parameters.