#[macro_export]
macro_rules! spawn {
(in $pool:expr, $($args:tt)*) => { $crate::_spawn_impl!(pool $pool, $($args)*) };
($($args:tt)*) => { $crate::_spawn_impl!(func $crate::spawn, $($args)*) }
}
#[macro_export]
#[doc(hidden)]
macro_rules! _spawn_impl {
(pool $pool:expr, () || $($body:tt)*) => {
$pool.spawn(
(),
|()|
$($body)*
)
};
(pool $pool:expr, ($($param:tt)*) || $($body:tt)*) => {
$pool.spawn(
$crate::_spawn_call_arg!($($param)*),
|($crate::_spawn_decl_arg!($($param)*))|
$($body)*
)
};
(func $func:path, () || $($body:tt)*) => {
$func(
(),
|()|
$($body)*
)
};
(func $func:path, ($($param:tt)*) || $($body:tt)*) => {
$func(
$crate::_spawn_call_arg!($($param)*),
|($crate::_spawn_decl_arg!($($param)*))|
$($body)*
)
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! _spawn_call_arg {
($expr:expr => mut $x:ident, $($tt:tt)*) => {(
$expr, $crate::_spawn_call_arg!($($tt)*)
)};
(*$expr:expr => $x:ident, $($tt:tt)*) => {(
*$expr, $crate::_spawn_call_arg!($($tt)*)
)};
($expr:expr => $x:ident, $($tt:tt)*) => {(
$expr, $crate::_spawn_call_arg!($($tt)*)
)};
($expr:expr => mut $x:ident) => {(
$expr,
)};
($expr:expr => $x:ident) => {(
$expr,
)};
(mut $x:ident, $($tt:tt)*) => {(
$x, $crate::_spawn_call_arg!($($tt)*)
)};
(mut $x:ident) => {(
$x,
)};
(*$x:ident, $($tt:tt)*) => {(
*$x, $crate::_spawn_call_arg!($($tt)*)
)};
($x:ident, $($tt:tt)*) => {(
$x, $crate::_spawn_call_arg!($($tt)*)
)};
(*$x:ident) => {(
*$x,
)};
($x:ident) => {(
$x,
)};
($unexpected:tt) => {
$crate::_spawn_unexpected($unexpected);
};
() => (())
}
#[macro_export]
#[doc(hidden)]
macro_rules! _spawn_decl_arg {
($expr:expr => mut $x:ident, $($tt:tt)*) => {(
mut $x, $crate::_spawn_decl_arg!($($tt)*)
)};
(*$expr:expr => $x:ident, $($tt:tt)*) => {(
$x, $crate::_spawn_decl_arg!($($tt)*)
)};
($expr:expr => $x:ident, $($tt:tt)*) => {(
$x, $crate::_spawn_decl_arg!($($tt)*)
)};
($expr:expr => mut $x:ident) => {(
mut $x,
)};
(*$expr:expr => $x:ident) => {(
$x,
)};
($expr:expr => $x:ident) => {(
$x,
)};
(mut $x:ident, $($tt:tt)*) => {(
mut $x, $crate::_spawn_decl_arg!($($tt)*)
)};
(mut $x:ident) => {(
mut $x,
)};
(*$x:ident, $($tt:tt)*) => {(
$x, $crate::_spawn_decl_arg!($($tt)*)
)};
($x:ident, $($tt:tt)*) => {(
$x, $crate::_spawn_decl_arg!($($tt)*)
)};
(*$x:ident) => {(
$x,
)};
($x:ident) => {(
$x,
)};
($unexpected:tt) => {
$crate::_spawn_unexpected($unexpected);
};
() => ()
}
#[macro_export]
#[doc(hidden)]
macro_rules! _spawn_unexpected {
() => {};
}