19
19
20
20
pub mod parameters;
21
21
22
- use std:: { fmt , iter, str, vec} ;
22
+ use std:: { iter, str, vec} ;
23
23
24
- use derive_more:: { Display , Error , From } ;
24
+ use derive_more:: with_trait :: { Debug , Display , Error as StdError , From } ;
25
25
use either:: Either ;
26
26
use nom:: { AsChar , Input } ;
27
27
use regex:: Regex ;
@@ -139,41 +139,32 @@ impl<'s> Expression<Spanned<'s>> {
139
139
/// [Cucumber Expression][0] and expanding it into a [`Regex`].
140
140
///
141
141
/// [0]: https://github.com/cucumber/cucumber-expressions#readme
142
- #[ derive( Clone , Debug , Display , Error , From ) ]
143
- pub enum Error < Input >
144
- where
145
- Input : fmt:: Display ,
146
- {
142
+ #[ derive( Clone , Debug , Display , From , StdError ) ]
143
+ pub enum Error < Input > {
147
144
/// Parsing error.
148
- #[ display( fmt = "Parsing failed: {}" , _0 ) ]
145
+ #[ display( "Parsing failed: {_0}" ) ]
149
146
Parsing ( parse:: Error < Input > ) ,
150
147
151
148
/// Expansion error.
152
- #[ display( fmt = "Failed to expand regex: {}" , _0 ) ]
149
+ #[ display( "Failed to expand regex: {_0}" ) ]
153
150
Expansion ( ParameterError < Input > ) ,
154
151
155
152
/// [`Regex`] creation error.
156
- #[ display( fmt = "Regex creation failed: {}" , _0 ) ]
153
+ #[ display( "Regex creation failed: {_0}" ) ]
157
154
Regex ( regex:: Error ) ,
158
155
}
159
156
160
157
/// Possible [`Parameter`] errors being used in an [`Expression`].
161
- #[ derive( Clone , Debug , Display , Error ) ]
162
- pub enum ParameterError < Input >
163
- where
164
- Input : fmt:: Display ,
165
- {
158
+ #[ derive( Clone , Debug , Display , StdError ) ]
159
+ pub enum ParameterError < Input > {
166
160
/// [`Parameter`] not found.
167
- #[ display( fmt = "Parameter `{}` not found." , _0 ) ]
161
+ #[ display( "Parameter `{_0 }` not found" ) ]
168
162
NotFound ( Input ) ,
169
163
170
164
/// Failed to rename [`Regex`] capturing group.
171
165
#[ display(
172
- fmt = "Failed to rename capturing groups in regex `{}` of \
173
- parameter `{}`: {}",
174
- re,
175
- parameter,
176
- err
166
+ "Failed to rename capturing groups in regex `{re}` of \
167
+ parameter `{parameter}`: {err}"
177
168
) ]
178
169
RenameRegexGroup {
179
170
/// [`Parameter`] name.
@@ -195,8 +186,8 @@ where
195
186
/// [0]: https://github.com/cucumber/cucumber-expressions#readme
196
187
/// [1]: https://git.io/J159T
197
188
/// [AST]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
198
- pub trait IntoRegexCharIter < I : fmt :: Display > {
199
- /// Type of an [`Iterator`] performing the expansion.
189
+ pub trait IntoRegexCharIter < I > {
190
+ /// Type of [`Iterator`] performing the expansion.
200
191
type Iter : Iterator < Item = Result < char , ParameterError < I > > > ;
201
192
202
193
/// Consumes this [AST] element returning an [`Iterator`] over [`char`]s
@@ -208,7 +199,7 @@ pub trait IntoRegexCharIter<I: fmt::Display> {
208
199
209
200
impl < I > IntoRegexCharIter < I > for Expression < I >
210
201
where
211
- I : Clone + fmt :: Display + Input ,
202
+ I : Clone + Display + Input ,
212
203
<I as Input >:: Item : AsChar ,
213
204
{
214
205
type Iter = ExpressionIter < I > ;
@@ -243,7 +234,7 @@ type ExpressionIter<I> = iter::Chain<
243
234
244
235
impl < I > IntoRegexCharIter < I > for SingleExpression < I >
245
236
where
246
- I : Clone + fmt :: Display + Input ,
237
+ I : Clone + Display + Input ,
247
238
<I as Input >:: Item : AsChar ,
248
239
{
249
240
type Iter = SingleExpressionIter < I > ;
@@ -289,7 +280,7 @@ type SingleExpressionIter<I> = Either<
289
280
290
281
impl < I > IntoRegexCharIter < I > for Alternation < I >
291
282
where
292
- I : fmt :: Display + Input ,
283
+ I : Display + Input ,
293
284
<I as Input >:: Item : AsChar ,
294
285
{
295
286
type Iter = AlternationIter < I > ;
@@ -344,7 +335,7 @@ type AlternationIterInner<I> = iter::Chain<
344
335
345
336
impl < I > IntoRegexCharIter < I > for Alternative < I >
346
337
where
347
- I : fmt :: Display + Input ,
338
+ I : Display + Input ,
348
339
<I as Input >:: Item : AsChar ,
349
340
{
350
341
type Iter = AlternativeIter < I > ;
@@ -378,7 +369,7 @@ type AlternativeIter<I> = Either<
378
369
379
370
impl < I > IntoRegexCharIter < I > for Optional < I >
380
371
where
381
- I : fmt :: Display + Input ,
372
+ I : Display + Input ,
382
373
<I as Input >:: Item : AsChar ,
383
374
{
384
375
type Iter = OptionalIter < I > ;
@@ -415,7 +406,7 @@ type MapOkChar<I> = fn(char) -> Result<char, ParameterError<I>>;
415
406
416
407
impl < I > IntoRegexCharIter < I > for Parameter < I >
417
408
where
418
- I : Clone + fmt :: Display + Input ,
409
+ I : Clone + Display + Input ,
419
410
<I as Input >:: Item : AsChar ,
420
411
{
421
412
type Iter = ParameterIter < I > ;
@@ -483,6 +474,7 @@ type ParameterIter<I> = Either<
483
474
/// [`Iterator`] for skipping a last [`Item`].
484
475
///
485
476
/// [`Item`]: Iterator::Item
477
+ #[ derive( Debug ) ]
486
478
pub struct SkipLast < Iter : Iterator > {
487
479
/// Inner [`Iterator`] to skip the last [`Item`] from.
488
480
///
@@ -502,18 +494,6 @@ where
502
494
}
503
495
}
504
496
505
- impl < Iter > fmt:: Debug for SkipLast < Iter >
506
- where
507
- Iter : fmt:: Debug + Iterator ,
508
- Iter :: Item : fmt:: Debug ,
509
- {
510
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
511
- f. debug_struct ( "SkipLast" )
512
- . field ( "iter" , & self . iter )
513
- . finish ( )
514
- }
515
- }
516
-
517
497
impl < Iter : Iterator > SkipLast < Iter > {
518
498
/// Creates a new [`SkipLast`] [`Iterator`].
519
499
pub fn new ( iter : Iter ) -> Self {
0 commit comments