#[doc(hidden)]
#[macro_export]
macro_rules! __assert_not_from_self {
(
$head:expr,
[$($a:tt)+],
[$($b:tt)*],
// $d should be the '$' symbol
$d:tt) => {{
macro_rules! __fail_if_starts_with {
([$($a)+]) => {
compile_error!(concat!(
"Cannot mutably borrow '",
stringify!($head),
concat!(".", $(stringify!($a)),+),
"' more than once at a time",
));
};
([$($a)+$d($d else:tt)+]) => {
compile_error!(concat!(
"Cannot mutably borrow '",
stringify!($head),
concat!(".", $(stringify!($a)),+),
concat!($d(stringify!($d else)),+),
"' and and its parent '",
stringify!($head),
concat!(".", $(stringify!($a)),+),
"' at the same time.",
));
};
($d else:tt) => {};
}
$(__fail_if_starts_with!($b);)*
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __assert_unique {
(@inner $head:expr, $current:tt, [$($prev:tt)*], [$next:tt $($rest:tt)*] ) => {
$crate::__assert_not_from_self!($head, $current, [$($prev)* $next $($rest)*], $);
$crate::__assert_unique!(@inner $head, $next, [$($prev)* $current], [$($rest)*]);
};
(@inner $head:expr, $current:tt, [$($prev:tt)*], [] ) => {
$crate::__assert_not_from_self!($head, $current, [$($prev)*], $);
};
($head:expr, [$first:tt $($rest:tt)+]) => {
$crate::__assert_unique!(@inner $head, $first, [], [$($rest)*]);
};
($head:expr, [$($first:tt)?]) => { };
}