Macro adapton::thunk
[−]
[src]
macro_rules! thunk { ( [ $nmop:expr ] ? $fun:expr ; $( $lab:ident :$arg:expr ),* ) => { ... }; [ $suspended_body:expr ] => { ... }; [ $nm:ident =>>> $suspended_body:expr ] => { ... }; [ $nm:expr =>> $suspended_body:expr ] => { ... }; ( $nm:expr =>> $f:ident :: < $( $ty:ty ),* > , $( $lab:ident : $arg:expr ),* ) => { ... }; ( $nm:expr =>> $f:path , $( $lab:ident : $arg:expr ),* ) => { ... }; ( $f:ident :: < $( $ty:ty ),* > , $( $lab:ident : $arg:expr ),* ) => { ... }; ( $f:path , $( $lab:ident : $arg:expr ),* ) => { ... }; ( $nm:expr =>> $f:ident =>> < $( $ty:ty ),* > , $( $lab1:ident : $arg1:expr ),* ;; $( $lab2:ident : $arg2:expr ),* ) => { ... }; }
Thunks
The following form is preferred:
thunk!( [ optional_name ]? fnexp ; lab1 : arg1, ..., labk : argk )
It accepts an optional name, of type Option<Name>
, and an arbitrary
function expression fnexp
(closure or function pointer). Like the
other forms, it requires that the programmer label each argument.
Example
let opnm : Option<Name> = Some(name_unit()); let t : Art<usize> = thunk!([opnm]? |x:usize,y:usize|{ if x > y { x } else { y }}; x:10, y:20 ); assert_eq!(force(&t), 20);