1use std::fmt::{self, Debug};
2
3use crate::expr::IndexedCaptures;
4use crate::haystack::{HaystackItem, HaystackOf};
5use crate::matcher::{Matcher, impl_all_captures_single, impl_all_matches_single};
6
7#[derive(#[automatically_derived]
impl<const N : u8> ::core::default::Default for Byte<N> {
#[inline]
fn default() -> Byte<N> { Byte {} }
}Default, #[automatically_derived]
impl<const N : u8> ::core::clone::Clone for Byte<N> {
#[inline]
fn clone(&self) -> Byte<N> { *self }
}Clone, #[automatically_derived]
impl<const N : u8> ::core::marker::Copy for Byte<N> { }Copy)]
8pub struct Byte<const N: u8>;
9
10impl<const N: u8> Matcher<u8> for Byte<N> {
11 fn matches<'a, H: HaystackOf<'a, u8>>(hay: &mut H) -> bool {
12 if hay.item() == Some(N) {
13 hay.progress();
14 true
15 } else {
16 false
17 }
18 }
19
20 u8
crate::matcher::AllMatchesSingle
u8
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<u8, H, Self>(hay);impl_all_matches_single!(u8);
21 u8
crate::matcher::AllCapturesSingle
u8
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<u8, H, Self>(hay, caps);impl_all_captures_single!(u8);
22}
23
24impl<const N: u8> Debug for Byte<N> {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 f.write_fmt(format_args!("{0:#04x}", N))write!(f, "{N:#04x}")
27 }
28}
29
30#[derive(#[automatically_derived]
impl<const A : u8, const B : u8> ::core::default::Default for ByteRange<A, B>
{
#[inline]
fn default() -> ByteRange<A, B> { ByteRange {} }
}Default, #[automatically_derived]
impl<const A : u8, const B : u8> ::core::clone::Clone for ByteRange<A, B> {
#[inline]
fn clone(&self) -> ByteRange<A, B> { *self }
}Clone, #[automatically_derived]
impl<const A : u8, const B : u8> ::core::marker::Copy for ByteRange<A, B> { }Copy)]
31pub struct ByteRange<const A: u8, const B: u8>;
32
33impl<const A: u8, const B: u8> Matcher<u8> for ByteRange<A, B> {
34 fn matches<'a, H: HaystackOf<'a, u8>>(hay: &mut H) -> bool {
35 if let Some(byte) = hay.item()
36 && A <= byte
37 && byte <= B
38 {
39 hay.progress();
40 true
41 } else {
42 false
43 }
44 }
45
46 u8
crate::matcher::AllMatchesSingle
u8
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<u8, H, Self>(hay);impl_all_matches_single!(u8);
47 u8
crate::matcher::AllCapturesSingle
u8
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<u8, H, Self>(hay, caps);impl_all_captures_single!(u8);
48}
49
50impl<const A: u8, const B: u8> Debug for ByteRange<A, B> {
51 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52 f.write_fmt(format_args!("[{0:#04x}-{1:#04x}]", A, B))write!(f, "[{A:#04x}-{B:#04x}]")
53 }
54}
55
56#[derive(#[automatically_derived]
impl<const N : char> ::core::default::Default for Scalar<N> {
#[inline]
fn default() -> Scalar<N> { Scalar {} }
}Default, #[automatically_derived]
impl<const N : char> ::core::clone::Clone for Scalar<N> {
#[inline]
fn clone(&self) -> Scalar<N> { *self }
}Clone, #[automatically_derived]
impl<const N : char> ::core::marker::Copy for Scalar<N> { }Copy)]
57pub struct Scalar<const N: char>;
58
59impl<const N: char> Matcher<char> for Scalar<N> {
60 fn matches<'a, H: HaystackOf<'a, char>>(hay: &mut H) -> bool {
61 if hay.item() == Some(N) {
62 hay.progress();
63 true
64 } else {
65 false
66 }
67 }
68
69 char
crate::matcher::AllMatchesSingle
char
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<char, H, Self>(hay);impl_all_matches_single!(char);
70 char
crate::matcher::AllCapturesSingle
char
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<char, H, Self>(hay, caps);impl_all_captures_single!(char);
71}
72
73impl<const N: char> Debug for Scalar<N> {
74 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75 f.write_fmt(format_args!("{0}", N.escape_debug()))write!(f, "{}", N.escape_debug())
76 }
77}
78
79#[derive(#[automatically_derived]
impl<const A : char, const B : char> ::core::default::Default for
ScalarRange<A, B> {
#[inline]
fn default() -> ScalarRange<A, B> { ScalarRange {} }
}Default, #[automatically_derived]
impl<const A : char, const B : char> ::core::clone::Clone for
ScalarRange<A, B> {
#[inline]
fn clone(&self) -> ScalarRange<A, B> { *self }
}Clone, #[automatically_derived]
impl<const A : char, const B : char> ::core::marker::Copy for
ScalarRange<A, B> {
}Copy)]
80pub struct ScalarRange<const A: char, const B: char>;
81
82impl<const A: char, const B: char> Matcher<char> for ScalarRange<A, B> {
83 fn matches<'a, H: HaystackOf<'a, char>>(hay: &mut H) -> bool {
84 if let Some(scalar) = hay.item()
85 && A <= scalar
86 && scalar <= B
87 {
88 hay.progress();
89 true
90 } else {
91 false
92 }
93 }
94
95 char
crate::matcher::AllMatchesSingle
char
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<char, H, Self>(hay);impl_all_matches_single!(char);
96 char
crate::matcher::AllCapturesSingle
char
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<char, H, Self>(hay, caps);impl_all_captures_single!(char);
97}
98
99impl<const A: char, const B: char> Debug for ScalarRange<A, B> {
100 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
101 f.write_fmt(format_args!("[{0}-{1}]", A.escape_debug(), B.escape_debug()))write!(f, "[{}-{}]", A.escape_debug(), B.escape_debug())
102 }
103}
104
105#[derive(#[automatically_derived]
impl ::core::default::Default for Always {
#[inline]
fn default() -> Always { Always {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for Always {
#[inline]
fn clone(&self) -> Always { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Always { }Copy)]
106pub struct Always;
107
108impl<I: HaystackItem> Matcher<I> for Always {
109 fn matches<'a, H: HaystackOf<'a, I>>(_hay: &mut H) -> bool {
110 true
111 }
112
113 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
114 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
115}
116
117impl Debug for Always {
118 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
119 f.write_fmt(format_args!("()"))write!(f, "()")
120 }
121}
122
123#[derive(#[automatically_derived]
impl ::core::default::Default for Start {
#[inline]
fn default() -> Start { Start {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for Start {
#[inline]
fn clone(&self) -> Start { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Start { }Copy)]
124pub struct Start;
125
126impl<I: HaystackItem> Matcher<I> for Start {
127 fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool {
128 hay.is_start()
129 }
130
131 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
132 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
133}
134
135impl Debug for Start {
136 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
137 f.write_fmt(format_args!("\\A"))write!(f, "\\A")
138 }
139}
140
141#[derive(#[automatically_derived]
impl ::core::default::Default for End {
#[inline]
fn default() -> End { End {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for End {
#[inline]
fn clone(&self) -> End { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for End { }Copy)]
142pub struct End;
143
144impl<I: HaystackItem> Matcher<I> for End {
145 fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool {
146 hay.is_end()
147 }
148
149 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
150 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
151}
152
153impl Debug for End {
154 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
155 f.write_fmt(format_args!("\\z"))write!(f, "\\z")
156 }
157}
158
159#[derive(#[automatically_derived]
impl ::core::default::Default for LineStart {
#[inline]
fn default() -> LineStart { LineStart {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for LineStart {
#[inline]
fn clone(&self) -> LineStart { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for LineStart { }Copy)]
160pub struct LineStart;
161
162impl<I: HaystackItem> Matcher<I> for LineStart {
163 fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool {
164 hay.is_line_start()
165 }
166
167 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
168 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
169}
170
171impl Debug for LineStart {
172 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
173 f.write_fmt(format_args!("^"))write!(f, "^")
174 }
175}
176
177#[derive(#[automatically_derived]
impl ::core::default::Default for LineEnd {
#[inline]
fn default() -> LineEnd { LineEnd {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for LineEnd {
#[inline]
fn clone(&self) -> LineEnd { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for LineEnd { }Copy)]
178pub struct LineEnd;
179
180impl<I: HaystackItem> Matcher<I> for LineEnd {
181 fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool {
182 hay.is_line_end()
183 }
184
185 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
186 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
187}
188
189impl Debug for LineEnd {
190 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
191 f.write_fmt(format_args!("$"))write!(f, "$")
192 }
193}
194
195#[derive(#[automatically_derived]
impl ::core::default::Default for CRLFStart {
#[inline]
fn default() -> CRLFStart { CRLFStart {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for CRLFStart {
#[inline]
fn clone(&self) -> CRLFStart { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CRLFStart { }Copy)]
196pub struct CRLFStart;
197
198impl<I: HaystackItem> Matcher<I> for CRLFStart {
199 fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool {
200 hay.is_crlf_start()
201 }
202
203 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
204 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
205}
206
207impl Debug for CRLFStart {
208 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209 f.write_fmt(format_args!("^"))write!(f, "^")
210 }
211}
212
213#[derive(#[automatically_derived]
impl ::core::default::Default for CRLFEnd {
#[inline]
fn default() -> CRLFEnd { CRLFEnd {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for CRLFEnd {
#[inline]
fn clone(&self) -> CRLFEnd { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CRLFEnd { }Copy)]
214pub struct CRLFEnd;
215
216impl<I: HaystackItem> Matcher<I> for CRLFEnd {
217 fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool {
218 hay.is_crlf_end()
219 }
220
221 I
crate::matcher::AllMatchesSingle
I
&mut H
hay
Self::AllMatches<'a, H>
crate::matcher::all_matches_single::<I, H, Self>(hay);impl_all_matches_single!(I);
222 I
crate::matcher::AllCapturesSingle
I
&mut H
hay
&mut IndexedCaptures
caps
Self::AllCaptures<'a, H>
crate::matcher::all_captures_single::<I, H, Self>(hay, caps);impl_all_captures_single!(I);
223}
224
225impl Debug for CRLFEnd {
226 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
227 f.write_fmt(format_args!("$"))write!(f, "$")
228 }
229}