Skip to main content

winnow/macros/
mod.rs

1mod dispatch;
2mod seq;
3mod unordered_seq;
4
5#[cfg(test)]
6macro_rules! assert_parse(
7    ($left: expr, $right: expr) => {
8        let res: $crate::error::ModalResult<_, $crate::error::InputError<_>> = $left;
9        snapbox::assert_data_eq!(snapbox::data::ToDebug::to_debug(&res), $right);
10    };
11);
12
13macro_rules! impl_partial_eq {
14    ($lhs:ty, $rhs:ty) => {
15        #[allow(unused_lifetimes)]
16        impl<'a> PartialEq<$rhs> for $lhs {
17            #[inline]
18            fn eq(&self, other: &$rhs) -> bool {
19                let l = self;
20                let r: &Self = other.as_ref();
21                PartialEq::eq(l, r)
22            }
23        }
24
25        #[allow(unused_lifetimes)]
26        impl<'a> PartialEq<$lhs> for $rhs {
27            #[inline]
28            fn eq(&self, other: &$lhs) -> bool {
29                PartialEq::eq(other, self)
30            }
31        }
32    };
33}
34
35macro_rules! impl_partial_ord {
36    ($lhs:ty, $rhs:ty) => {
37        #[allow(unused_lifetimes)]
38        impl<'a> PartialOrd<$rhs> for $lhs {
39            #[inline]
40            fn partial_cmp(&self, other: &$rhs) -> Option<Ordering> {
41                let l = self;
42                let r: &Self = other.as_ref();
43                PartialOrd::partial_cmp(l, r)
44            }
45        }
46
47        #[allow(unused_lifetimes)]
48        impl<'a> PartialOrd<$lhs> for $rhs {
49            #[inline]
50            fn partial_cmp(&self, other: &$lhs) -> Option<Ordering> {
51                PartialOrd::partial_cmp(other, self)
52            }
53        }
54    };
55}
56
57#[cfg(all(test, feature = "ascii"))]
58mod tests;