wiwiwiwiwiwiwiwiwiwi/
with_cloned.rs#[macro_export]
macro_rules! with_cloned {
($($stuff:tt)*) => {
$crate::__with_cloned_impl! { $($stuff)* }
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __with_cloned_impl {
{ _ in $($stuff:tt)* } => {
{
$($stuff)*
}
};
{ mut $($thing:ident),+ in $($stuff:tt)* } => {
{
$(
#[allow(unused_mut)]
let mut $thing = ::core::clone::Clone::clone(&$thing);
)+
$($stuff)*
}
};
{ $($thing:ident),+ in $($stuff:tt)* } => {
{
$(
let $thing = ::core::clone::Clone::clone(&$thing);
)+
$($stuff)*
}
};
}
#[macro_export]
macro_rules! with_cloned_2 {
($($stuff:tt)*) => {
$crate::__with_cloned_impl_2! { $($stuff)* }
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __with_cloned_impl_2 {
{ $(,)? in $($stuff:tt)* } => {
{
$($stuff)*
}
};
{ $(,)? _ $($rest:tt)* } => {
{
$crate::__with_cloned_impl_2! { $($rest)* }
}
};
{ $(,)? mut &$thing:ident $($rest:tt)* } => {
{
let mut $thing = ::core::clone::Clone::clone($thing);
$crate::__with_cloned_impl_2! { $($rest)* }
}
};
{ $(,)? mut $thing:ident $($rest:tt)* } => {
{
let mut $thing = ::core::clone::Clone::clone(&$thing);
$crate::__with_cloned_impl_2! { $($rest)* }
}
};
{ $(,)? &$thing:ident $($rest:tt)* } => {
{
let $thing = ::core::clone::Clone::clone($thing);
$crate::__with_cloned_impl_2! { $($rest)* }
}
};
{ $(,)? $thing:ident $($rest:tt)* } => {
{
let $thing = ::core::clone::Clone::clone(&$thing);
$crate::__with_cloned_impl_2! { $($rest)* }
}
};
}
#[macro_export]
macro_rules! with_cloned_3 {
($($stuff:tt)*) => {
$crate::__with_cloned_impl_3! { $($stuff)* }
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __with_cloned_impl_3 {
{ _ => $rest:expr } => {
$rest
};
{ mut $name:ident = $thing:expr => $rest:expr } => {
{
let mut $name = ::core::clone::Clone::clone(&$thing);
$rest
}
};
{ $name:ident = $thing:expr => $rest:expr } => {
{
let $name = ::core::clone::Clone::clone(&$thing);
$rest
}
};
{ mut $name:ident = $thing:expr, $($rest:tt)* } => {
{
let mut $name = ::core::clone::Clone::clone(&$thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ $name:ident = $thing:expr, $($rest:tt)* } => {
{
let $name = ::core::clone::Clone::clone(&$thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ mut *$thing:ident => $rest:expr } => {
{
let mut $thing = ::core::clone::Clone::clone($thing);
$rest
}
};
{ *$thing:ident => $rest:expr } => {
{
let $thing = ::core::clone::Clone::clone($thing);
$rest
}
};
{ mut *$thing:ident, $($rest:tt)* } => {
{
let mut $thing = ::core::clone::Clone::clone($thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ *$thing:ident, $($rest:tt)* } => {
{
let $thing = ::core::clone::Clone::clone($thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ mut **$thing:ident => $rest:expr } => {
{
let mut $thing = ::core::clone::Clone::clone(*$thing);
$rest
}
};
{ **$thing:ident => $rest:expr } => {
{
let $thing = ::core::clone::Clone::clone(*$thing);
$rest
}
};
{ mut **$thing:ident, $($rest:tt)* } => {
{
let mut $thing = ::core::clone::Clone::clone(*$thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ **$thing:ident, $($rest:tt)* } => {
{
let $thing = ::core::clone::Clone::clone(*$thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ mut $thing:ident => $rest:expr } => {
{
let mut $thing = ::core::clone::Clone::clone(&$thing);
$rest
}
};
{ $thing:ident => $rest:expr } => {
{
let $thing = ::core::clone::Clone::clone(&$thing);
$rest
}
};
{ mut $thing:ident, $($rest:tt)* } => {
{
let mut $thing = ::core::clone::Clone::clone(&$thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
{ $thing:ident, $($rest:tt)* } => {
{
let $thing = ::core::clone::Clone::clone(&$thing);
$crate::__with_cloned_impl_3! { $($rest)* }
}
};
}
#[macro_export]
macro_rules! with_cloned_4 {
($($stuff:tt)*) => {
$crate::__with_cloned_impl_4! { $($stuff)* }
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __with_cloned_impl_4 {
{ _ => $expr:expr } => { $expr };
{ mut $item:ident = $expr:expr, $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { $($expr)* }, $($rest)* }
};
{ $item:ident = $expr:expr, $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl { $item } { $($expr)* }, $($rest)* }
};
{ mut $item:ident = $expr:expr => $body:expr } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { $expr } => $body }
};
{ $item:ident = $expr:expr => $body:expr } => {
$crate::__with_cloned_impl_4! { @impl { $item } { $expr } => $body }
};
{ mut ($($expr:tt)*) $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $($expr)* } { $($expr)* } $($rest)* }
};
{ ($($expr:tt)*) $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $($expr)* } { $($expr)* } $($rest)* }
};
{ mut *$item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { *$item } $($rest)* }
};
{ *$item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl { $item } { *$item } $($rest)* }
};
{ mut **$item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { **$item } $($rest)* }
};
{ **$item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl { $item } { **$item } $($rest)* }
};
{ mut $parent:ident.$item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { $parent.$item } $($rest)* }
};
{ $parent:ident.$item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl { $item } { $parent.$item } $($rest)* }
};
{ mut $item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { $item } $($rest)* }
};
{ $item:ident $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl { $item } { $item } $($rest)* }
};
{ @impl mut { $item:ident } { $expr:expr }, $($rest:tt)* } => {
{
let mut $item = ::core::clone::Clone::clone(&$expr);
$crate::__with_cloned_impl_4! { $($rest)* }
}
};
{ @impl { $item:ident } { $expr:expr }, $($rest:tt)* } => {
{
let $item = ::core::clone::Clone::clone(&$expr);
$crate::__with_cloned_impl_4! { $($rest)* }
}
};
{ @impl mut { $item:ident } { $expr:expr } => $body:expr } => {
{
let mut $item = ::core::clone::Clone::clone(&$expr);
$body
}
};
{ @impl { $item:ident } { $expr:expr } => $body:expr } => {
{
let $item = ::core::clone::Clone::clone(&$expr);
$body
}
};
{ @impl mut {} { $item:ident } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut { $item } { $expr } $($rest)* }
};
{ @impl {} { $item:ident } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl { $item } { $expr } $($rest)* }
};
{ @impl mut {} { *$($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { *$($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $($item_rest)* } { $expr } $($rest)* }
};
{ @impl mut {} { $item:ident.as_ref() $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { $item:ident.as_ref() $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl mut {} { $item:ident.as_mut() $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { $item:ident.as_mut() $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl mut {} { $item:ident($($args:tt)*) $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { $item:ident($($args:tt)*) $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl mut {} { $parent:ident.$($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { $parent:ident.$($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $($item_rest)* } { $expr } $($rest)* }
};
{ @impl mut {} { $item:ident? $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { $item:ident? $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $item $($item_rest)* } { $expr } $($rest)* }
};
{ @impl mut {} { ($($item:tt)*) $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl mut {} { $($item)* $($item_rest)* } { $expr } $($rest)* }
};
{ @impl {} { ($($item:tt)*) $($item_rest:tt)* } { $expr:expr } $($rest:tt)* } => {
$crate::__with_cloned_impl_4! { @impl {} { $($item)* $($item_rest)* } { $expr } $($rest)* }
};
{} => { compile_error! { "uwu" } };
}