#[doc(hidden)]
#[macro_export]
macro_rules! __strip_custom_attributes {
{
@() @($($output:tt)*)
@($($m_done:tt)*)
} => {
$($m_done)*
$($output)*
};
{
@(
#[method $($args:tt)*]
$($m_rest:tt)*
)
@($($output:tt)*)
@($($m_done:tt)*)
} => {
$crate::__strip_custom_attributes! {
@($($m_rest)*)
@($($output)*)
@($($m_done)*)
}
};
{
@(
#[method_id $($args:tt)*]
$($m_rest:tt)*
)
@($($output:tt)*)
@($($m_done:tt)*)
} => {
$crate::__strip_custom_attributes! {
@($($m_rest)*)
@($($output)*)
@($($m_done)*)
}
};
{
@(
#[optional $($args:tt)*]
$($m_rest:tt)*
)
@($($output:tt)*)
@($($m_done:tt)*)
} => {
$crate::__strip_custom_attributes! {
@($($m_rest)*)
@($($output)*)
@($($m_done)*)
}
};
{
@(
#[$($m_checked:tt)*]
$($m_rest:tt)*
)
@($($output:tt)*)
@($($m_done:tt)*)
} => {
$crate::__strip_custom_attributes! {
@($($m_rest)*)
@($($output)*)
@(
$($m_done)*
#[$($m_checked)*]
)
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __extract_and_apply_cfg_attributes {
{
@() @($($output:tt)*)
} => {
$($output)*
};
{
@(
#[cfg $($args:tt)*]
$($m_rest:tt)*
)
@($($output:tt)*)
} => {
#[cfg $($args)*]
{
$crate::__extract_and_apply_cfg_attributes! {
@($($m_rest)*)
@($($output)*)
}
}
};
{
@(
#[$($m_ignored:tt)*]
$($m_rest:tt)*
)
@($($output:tt)*)
} => {
$crate::__extract_and_apply_cfg_attributes! {
@($($m_rest)*)
@($($output)*)
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __extract_custom_attributes {
{
@()
@($out_macro:path)
@($($macro_args:tt)*)
@()
@($($m_optional:tt)*)
} => {
compile_error!("must specify the desired selector using `#[method(...)]` or `#[method_id(...)]`")
};
{
@()
@($out_macro:path)
@($($macro_args:tt)*)
@($($m_method:tt)*)
@($($m_optional:tt)*)
} => {{
$out_macro! {
$($macro_args)*
@($($m_method)*)
@($($m_optional)*)
}
}};
{
@(
#[method($($args:tt)*)]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@()
@($($m_optional:tt)*)
} => {
$crate::__extract_custom_attributes! {
@($($rest)*)
@($out_macro)
@($($macro_args)*)
@(#[method($($args)*)])
@($($m_optional)*)
}
};
{
@(
#[method($($args:tt)*)]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@($($m_method:tt)*)
@($($m_optional:tt)*)
} => {
compile_error!("cannot specify the `method`/`method_id` attribute twice")
};
{
@(
#[method_id($($args:tt)*)]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@()
@($($m_optional:tt)*)
} => {
$crate::__extract_custom_attributes! {
@($($rest)*)
@($out_macro)
@($($macro_args)*)
@(#[method_id($($args)*)])
@($($m_optional)*)
}
};
{
@(
#[method_id($($args:tt)*)]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@($($m_method:tt)*)
@($($m_optional:tt)*)
} => {
compile_error!("cannot specify the `method`/`method_id` attribute twice")
};
{
@(
#[optional]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@($($m_method:tt)*)
@()
} => {
$crate::__extract_custom_attributes! {
@($($rest)*)
@($out_macro)
@($($macro_args)*)
@($($m_method)*)
@(#[optional])
}
};
{
@(
#[optional]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@($($m_method:tt)*)
@($($m_optional:tt)*)
} => {
compile_error!("cannot specify the `optional` attribute twice")
};
{
@(
#[$($m_checked:tt)*]
$($rest:tt)*
)
@($out_macro:path)
@($($macro_args:tt)*)
@($($m_method:tt)*)
@($($m_optional:tt)*)
} => {
$crate::__extract_custom_attributes! {
@($($rest)*)
@($out_macro)
@($($macro_args)*)
@($($m_method)*)
@($($m_optional)*)
}
};
}