#[doc(hidden)]
#[macro_export]
macro_rules! __make_rc_upgrade_stmt {
(% $expr:expr => $ident:ident) => {
let $ident = if let Some(x) = ::std::rc::Weak::upgrade(&$ident) { x } else { return; };
};
(% $e:ident) => {
let $e = if let Some(x) = ::std::rc::Weak::upgrade(&$e) { x } else { return; };
};
($($input:tt)*) => {};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __make_stmt {
(% $expr:expr => $ident:ident) => {
let $ident = ::std::rc::Rc::downgrade(&$expr);
};
(% $e:ident) => {
let $e = ::std::rc::Rc::downgrade(&$e);
};
(mut $ident:ident <- $expr:expr) => {
let mut $ident = $expr;
};
($ident:ident <- $expr:expr) => {
let $ident = $expr;
};
($expr:expr => mut $ident:ident) => {
let mut $ident = $expr.clone();
};
($expr:expr => $ident:ident) => {
let $ident = $expr.clone();
};
(mut $e:ident) => {
let mut $e = $e.clone();
};
($e:ident) => {
let $e = $e.clone();
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __e_inner {
(
input = (),
current_input = (),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (),
header = ($($header:tt)*),
body = ($body:tt),
) => {{
$($stmt)*
$($header)* {
$($rc_upgrade_stmt)*
$body
}
}};
(
input = (, $($rest:tt)*),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (),
header = ($($header:tt)*),
body = ($body:tt),
) => {
$crate::__e_inner!{
input = ($($rest)*),
current_input = (),
rc_upgrade_stmts = ($crate::__make_rc_upgrade_stmt!{$($current_input)*} $($rc_upgrade_stmt)*),
stmts = ($crate::__make_stmt!{$($current_input)*} $($stmt)*),
closure_input = (),
header = ($($header)*),
body = ($body),
}
};
(
input = (),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (),
header = ($($header:tt)*),
body = ($body:tt),
) => {
$crate::__e_inner!{
input = (),
current_input = (),
rc_upgrade_stmts = ($crate::__make_rc_upgrade_stmt!{$($current_input)*} $($rc_upgrade_stmt)*),
stmts = ($crate::__make_stmt!{$($current_input)*} $($stmt)*),
closure_input = (),
header = ($($header)*),
body = ($body),
}
};
(
input = ($current:tt $($rest:tt)*),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (),
header = ($($header:tt)*),
body = ($body:tt),
) => {
$crate::__e_inner!{
input = ($($rest)*),
current_input = ($($current_input)* $current),
rc_upgrade_stmts = ($($rc_upgrade_stmt)*),
stmts = ($($stmt)*),
closure_input = (),
header = ($($header)*),
body = ($body),
}
};
(
input = ($($rest:tt)*),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (move || $($closure_input:tt)*),
header = ($($header:tt)*),
body = (),
) => {
$crate::__e_inner!{
input = ($($rest)*),
current_input = ($($current_input)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt)*),
stmts = ($($stmt)*),
closure_input = (),
header = ($($header)* move ||),
body = ({ $($closure_input)* }),
}
};
(
input = ($($rest:tt)*),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (move | $($closure_input:tt)*),
header = ($($header:tt)*),
body = (),
) => {
$crate::__e_inner!{
input = ($($rest)*),
current_input = ($($current_input)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt)*),
stmts = ($($stmt)*),
closure_input = ($($closure_input)*),
header = ($($header)* move |),
body = (),
}
};
(
input = ($($rest:tt)*),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = (| $($current:tt)*),
header = ($($header:tt)*),
body = (),
) => {
$crate::__e_inner!{
input = ($($rest)*),
current_input = ($($current_input)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt)*),
stmts = ($($stmt)*),
closure_input = (),
header = ($($header)* |),
body = ({ $($current)* }),
}
};
(
input = ($($rest:tt)*),
current_input = ($($current_input:tt)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt:tt)*),
stmts = ($($stmt:tt)*),
closure_input = ($current:tt $($closure_input:tt)*),
header = ($($header:tt)*),
body = (),
) => {
$crate::__e_inner!{
input = ($($rest)*),
current_input = ($($current_input)*),
rc_upgrade_stmts = ($($rc_upgrade_stmt)*),
stmts = ($($stmt)*),
closure_input = ($($closure_input)*),
header = ($($header)* $current),
body = (),
}
};
}
#[macro_export]
macro_rules! enclose {
(($($input:tt)*) $($closure_input:tt)+) => {
$crate::__e_inner!{
input = ($($input)*),
current_input = (),
rc_upgrade_stmts = (),
stmts = (),
closure_input = ($($closure_input)+),
header = (),
body = (),
};
};
}