macro_rules! ret_to { ([$cx:expr], |$this:pat_param, $cxid:pat_param, $arg:ident : Option<$t:ty>| $($body:tt)+) => { ... }; ([$cx:expr], move | $($x:tt)*) => { ... }; ($($x:tt)*) => { ... }; }
Expand description
Create a Ret
instance for actor calls
This is guaranteed to be called exactly once. So it will be
called even if the Ret
is dropped. (The guarantee can be
broken by leaking memory using mem::forget
, though, so don’t do
that!) The message is passed as Some(msg)
if called normally,
or as None
if the Ret
instance was dropped, e.g. if it
couldn’t be delivered somewhere. The underlying closure is a
FnOnce
, so non-Copy types can be passed. The syntax is the same
as for fwd_to!
, and the message types are specified as normal.
However the message is received in a single argument on the
receiving method, either Option<type>
for a single type, or else
Option<(type1, type2...)>
.
See ret_some_to!
instead if you’re only interested in the
Some(msg)
case.
ret_to!(...arguments-as-for-fwd_to-macro...);
The closure form must use a single Option
as above as the
argument type, containing all the types passed from the Ret
.
Implemented using Ret::to_actor
or Ret::to_actor_prep
.