1use crate::Pattern;
2
3impl Pattern for char {
4 type SplitIter<'a> = core::str::Split<'a, char>;
5
6 type MatchesIter<'a> = core::str::Matches<'a, char>;
7
8 type RMatchesIter<'a> = core::str::RMatches<'a, char>;
9
10 type MatchIndicesIter<'a> = core::str::MatchIndices<'a, char>;
11
12 type RMatchIndicesIter<'a> = core::str::RMatchIndices<'a, char>;
13
14 #[inline]
15 fn split<'a>(self, s: &'a str) -> Self::SplitIter<'a>
16 where
17 Self: 'a,
18 {
19 s.split(self)
20 }
21
22 #[inline]
23 fn split_once<'a>(&self, s: &'a str) -> Option<(&'a str, &'a str)> {
24 s.split_once(*self)
25 }
26
27 #[inline]
28 fn rsplit_once<'a>(&self, s: &'a str) -> Option<(&'a str, &'a str)> {
29 s.rsplit_once(*self)
30 }
31
32 #[inline]
33 fn strip_prefix<'a>(&self, s: &'a str) -> Option<&'a str> {
34 s.strip_prefix(*self)
35 }
36
37 #[inline]
38 fn strip_suffix<'a>(&self, s: &'a str) -> Option<&'a str> {
39 s.strip_suffix(*self)
40 }
41
42 #[inline]
43 fn matches<'a>(self, s: &'a str) -> Self::MatchesIter<'a>
44 where
45 Self: 'a,
46 {
47 s.matches(self)
48 }
49
50 #[inline]
51 fn rmatches<'a>(self, s: &'a str) -> Self::RMatchesIter<'a>
52 where
53 Self: 'a,
54 {
55 s.rmatches(self)
56 }
57
58 #[inline]
59 fn match_indices<'a>(self, s: &'a str) -> Self::MatchIndicesIter<'a>
60 where
61 Self: 'a,
62 {
63 s.match_indices(self)
64 }
65
66 #[inline]
67 fn rmatch_indices<'a>(self, s: &'a str) -> Self::RMatchIndicesIter<'a>
68 where
69 Self: 'a,
70 {
71 s.rmatch_indices(self)
72 }
73
74 #[inline]
75 fn contains(&self, s: &str) -> bool {
76 s.contains(*self)
77 }
78
79 #[inline]
80 fn starts_with(&self, s: &str) -> bool {
81 s.starts_with(*self)
82 }
83
84 #[inline]
85 fn ends_with(&self, s: &str) -> bool {
86 s.ends_with(*self)
87 }
88
89 #[inline]
90 fn find(&self, s: &str) -> Option<usize> {
91 s.find(*self)
92 }
93
94 #[inline]
95 fn rfind(&self, s: &str) -> Option<usize> {
96 s.rfind(*self)
97 }
98}
99
100impl<'p> Pattern for &'p str {
101 type SplitIter<'a>
102 = core::str::Split<'a, &'p str>
103 where
104 Self: 'a;
105 type MatchesIter<'a>
106 = core::str::Matches<'a, &'p str>
107 where
108 Self: 'a;
109 type RMatchesIter<'a>
110 = core::str::RMatches<'a, &'p str>
111 where
112 Self: 'a;
113 type MatchIndicesIter<'a>
114 = core::str::MatchIndices<'a, &'p str>
115 where
116 Self: 'a;
117 type RMatchIndicesIter<'a>
118 = core::str::RMatchIndices<'a, &'p str>
119 where
120 Self: 'a;
121
122 #[inline]
123 fn split<'a>(self, s: &'a str) -> Self::SplitIter<'a>
124 where
125 Self: 'a,
126 {
127 s.split(self)
128 }
129
130 #[inline]
131 fn matches<'a>(self, s: &'a str) -> Self::MatchesIter<'a>
132 where
133 Self: 'a,
134 {
135 s.matches(self)
136 }
137
138 #[inline]
139 fn rmatches<'a>(self, s: &'a str) -> Self::RMatchesIter<'a>
140 where
141 Self: 'a,
142 {
143 s.rmatches(self)
144 }
145
146 #[inline]
147 fn match_indices<'a>(self, s: &'a str) -> Self::MatchIndicesIter<'a>
148 where
149 Self: 'a,
150 {
151 s.match_indices(self)
152 }
153
154 #[inline]
155 fn rmatch_indices<'a>(self, s: &'a str) -> Self::RMatchIndicesIter<'a>
156 where
157 Self: 'a,
158 {
159 s.rmatch_indices(self)
160 }
161
162 #[inline]
163 fn split_once<'a>(&self, s: &'a str) -> Option<(&'a str, &'a str)> {
164 s.split_once(*self)
165 }
166
167 #[inline]
168 fn rsplit_once<'a>(&self, s: &'a str) -> Option<(&'a str, &'a str)> {
169 s.rsplit_once(*self)
170 }
171
172 #[inline]
173 fn strip_prefix<'a>(&self, s: &'a str) -> Option<&'a str> {
174 s.strip_prefix(*self)
175 }
176
177 #[inline]
178 fn strip_suffix<'a>(&self, s: &'a str) -> Option<&'a str> {
179 s.strip_suffix(*self)
180 }
181
182 #[inline]
183 fn contains(&self, s: &str) -> bool {
184 s.contains(*self)
185 }
186
187 #[inline]
188 fn starts_with(&self, s: &str) -> bool {
189 s.starts_with(*self)
190 }
191
192 #[inline]
193 fn ends_with(&self, s: &str) -> bool {
194 s.ends_with(*self)
195 }
196
197 #[inline]
198 fn find(&self, s: &str) -> Option<usize> {
199 s.find(*self)
200 }
201
202 #[inline]
203 fn rfind(&self, s: &str) -> Option<usize> {
204 s.rfind(*self)
205 }
206}