#![doc(hidden)]
#[macro_export]
#[doc(hidden)]
macro_rules! __matches_pattern {
($($t:tt)*) => { $crate::matches_pattern_internal!($($t)*) }
}
#[doc(hidden)]
#[macro_export]
macro_rules! matches_pattern_internal {
(
[$($struct_name:tt)*],
{ $field_name:ident : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!($crate::matchers::field!($($struct_name)*.$field_name, $matcher))
)
};
(
[$($struct_name:tt)*],
{ *$field_name:ident : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!($crate::matchers::field!($($struct_name)*.$field_name, $crate::matchers::points_to($matcher)))
)
};
(
[$($struct_name:tt)*],
{ $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!($crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$matcher,
))
)
};
(
[$($struct_name:tt)*],
{ * $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!(
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$crate::matchers::points_to($matcher),
)
)
)
};
(
[$($struct_name:tt)*],
{ $field_name:ident : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$crate::matchers::field!($($struct_name)*.$field_name, $matcher)
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
[$($struct_name:tt)*],
{ *$field_name:ident : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$crate::matchers::field!($($struct_name)*.$field_name, $crate::matchers::points_to($matcher))
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
[$($struct_name:tt)*],
{ $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$matcher,
)
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
[$($struct_name:tt)*],
{ * $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$crate::matchers::points_to($matcher),
)
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ $field_name:ident : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.$field_name, $matcher)
),
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ *$field_name:ident : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.$field_name, $crate::matchers::points_to($matcher))
),
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!(
$($processed)*,
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$matcher,
)
),
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ * $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr $(,)? }
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!(
$($processed)*,
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$crate::matchers::points_to($matcher),
)
),
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ $field_name:ident : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.$field_name, $matcher)
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ *$field_name:ident : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.$field_name, $crate::matchers::points_to($matcher))
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$matcher,
)
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
{ * $property_name:ident($($argument:expr),* $(,)?) : $matcher:expr, $($rest:tt)* }
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::result_of!(
|s: &$($struct_name)*| s.$property_name($($argument),*),
$crate::matchers::points_to($matcher),
)
),
[$($struct_name)*],
{ $($rest)* }
)
};
(
[$($struct_name:tt)*],
) => {
$crate::matchers::predicate(|v| matches!(v, $($struct_name)*))
.with_description(
concat!("is ", stringify!($($struct_name)*)),
concat!("is not ", stringify!($($struct_name)*)),
)
};
(
[$($struct_name:tt)*],
($matcher:expr $(,)?)
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!($crate::matchers::field!($($struct_name)*.0, $matcher))
)
};
(
[$($struct_name:tt)*],
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$crate::matchers::field!($($struct_name)*.0, $matcher)
),
[$($struct_name)*],
1,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
$field:tt,
($matcher:expr $(,)?)
) => {
$crate::matchers::__internal::is(
stringify!($($struct_name)*),
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.$field, $matcher)
),
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
1,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.1, $matcher)
),
[$($struct_name)*],
2,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
2,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.2, $matcher)
),
[$($struct_name)*],
3,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
3,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.3, $matcher)
),
[$($struct_name)*],
4,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
4,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.4, $matcher)
),
[$($struct_name)*],
5,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
5,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.5, $matcher)
),
[$($struct_name)*],
6,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
6,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.6, $matcher)
),
[$($struct_name)*],
7,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
7,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.7, $matcher)
),
[$($struct_name)*],
8,
($($rest)*)
)
};
(
$crate::matchers::all!($($processed:tt)*),
[$($struct_name:tt)*],
8,
($matcher:expr, $($rest:tt)*)
) => {
$crate::matches_pattern_internal!(
$crate::matchers::all!(
$($processed)*,
$crate::matchers::field!($($struct_name)*.8, $matcher)
),
[$($struct_name)*],
9,
($($rest)*)
)
};
([$($struct_name:tt)*], $first:tt $($rest:tt)*) => {
$crate::matches_pattern_internal!([$($struct_name)* $first], $($rest)*)
};
($first:tt $($rest:tt)*) => {{
$crate::matches_pattern_internal!([$first], $($rest)*)
}};
}
#[macro_export]
#[doc(hidden)]
macro_rules! __pat {
($($t:tt)*) => { $crate::matches_pattern_internal!($($t)*) }
}