1919
2020pub mod parameters;
2121
22- use std:: { fmt , iter, str, vec} ;
22+ use std:: { iter, str, vec} ;
2323
24- use derive_more:: { Display , Error , From } ;
24+ use derive_more:: with_trait :: { Debug , Display , Error as StdError , From } ;
2525use either:: Either ;
2626use nom:: { AsChar , Input } ;
2727use regex:: Regex ;
@@ -139,41 +139,32 @@ impl<'s> Expression<Spanned<'s>> {
139139/// [Cucumber Expression][0] and expanding it into a [`Regex`].
140140///
141141/// [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 > {
147144 /// Parsing error.
148- #[ display( fmt = "Parsing failed: {}" , _0 ) ]
145+ #[ display( "Parsing failed: {_0}" ) ]
149146 Parsing ( parse:: Error < Input > ) ,
150147
151148 /// Expansion error.
152- #[ display( fmt = "Failed to expand regex: {}" , _0 ) ]
149+ #[ display( "Failed to expand regex: {_0}" ) ]
153150 Expansion ( ParameterError < Input > ) ,
154151
155152 /// [`Regex`] creation error.
156- #[ display( fmt = "Regex creation failed: {}" , _0 ) ]
153+ #[ display( "Regex creation failed: {_0}" ) ]
157154 Regex ( regex:: Error ) ,
158155}
159156
160157/// 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 > {
166160 /// [`Parameter`] not found.
167- #[ display( fmt = "Parameter `{}` not found." , _0 ) ]
161+ #[ display( "Parameter `{_0 }` not found" ) ]
168162 NotFound ( Input ) ,
169163
170164 /// Failed to rename [`Regex`] capturing group.
171165 #[ 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}"
177168 ) ]
178169 RenameRegexGroup {
179170 /// [`Parameter`] name.
@@ -195,8 +186,8 @@ where
195186/// [0]: https://github.com/cucumber/cucumber-expressions#readme
196187/// [1]: https://git.io/J159T
197188/// [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.
200191 type Iter : Iterator < Item = Result < char , ParameterError < I > > > ;
201192
202193 /// Consumes this [AST] element returning an [`Iterator`] over [`char`]s
@@ -208,7 +199,7 @@ pub trait IntoRegexCharIter<I: fmt::Display> {
208199
209200impl < I > IntoRegexCharIter < I > for Expression < I >
210201where
211- I : Clone + fmt :: Display + Input ,
202+ I : Clone + Display + Input ,
212203 <I as Input >:: Item : AsChar ,
213204{
214205 type Iter = ExpressionIter < I > ;
@@ -243,7 +234,7 @@ type ExpressionIter<I> = iter::Chain<
243234
244235impl < I > IntoRegexCharIter < I > for SingleExpression < I >
245236where
246- I : Clone + fmt :: Display + Input ,
237+ I : Clone + Display + Input ,
247238 <I as Input >:: Item : AsChar ,
248239{
249240 type Iter = SingleExpressionIter < I > ;
@@ -289,7 +280,7 @@ type SingleExpressionIter<I> = Either<
289280
290281impl < I > IntoRegexCharIter < I > for Alternation < I >
291282where
292- I : fmt :: Display + Input ,
283+ I : Display + Input ,
293284 <I as Input >:: Item : AsChar ,
294285{
295286 type Iter = AlternationIter < I > ;
@@ -344,7 +335,7 @@ type AlternationIterInner<I> = iter::Chain<
344335
345336impl < I > IntoRegexCharIter < I > for Alternative < I >
346337where
347- I : fmt :: Display + Input ,
338+ I : Display + Input ,
348339 <I as Input >:: Item : AsChar ,
349340{
350341 type Iter = AlternativeIter < I > ;
@@ -378,7 +369,7 @@ type AlternativeIter<I> = Either<
378369
379370impl < I > IntoRegexCharIter < I > for Optional < I >
380371where
381- I : fmt :: Display + Input ,
372+ I : Display + Input ,
382373 <I as Input >:: Item : AsChar ,
383374{
384375 type Iter = OptionalIter < I > ;
@@ -415,7 +406,7 @@ type MapOkChar<I> = fn(char) -> Result<char, ParameterError<I>>;
415406
416407impl < I > IntoRegexCharIter < I > for Parameter < I >
417408where
418- I : Clone + fmt :: Display + Input ,
409+ I : Clone + Display + Input ,
419410 <I as Input >:: Item : AsChar ,
420411{
421412 type Iter = ParameterIter < I > ;
@@ -483,6 +474,7 @@ type ParameterIter<I> = Either<
483474/// [`Iterator`] for skipping a last [`Item`].
484475///
485476/// [`Item`]: Iterator::Item
477+ #[ derive( Debug ) ]
486478pub struct SkipLast < Iter : Iterator > {
487479 /// Inner [`Iterator`] to skip the last [`Item`] from.
488480 ///
@@ -502,18 +494,6 @@ where
502494 }
503495}
504496
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-
517497impl < Iter : Iterator > SkipLast < Iter > {
518498 /// Creates a new [`SkipLast`] [`Iterator`].
519499 pub fn new ( iter : Iter ) -> Self {
0 commit comments