@@ -2374,18 +2374,18 @@ impl<'c, 'h> core::iter::FusedIterator for SubCaptureMatches<'c, 'h> {}
2374
2374
/// Contains helper trait for blanket implementation for [`Replacer`].
2375
2375
mod replacer_closure {
2376
2376
use super :: * ;
2377
- /// If a closure implements this for all `'a `, then it also implements
2378
- /// [`Replacer`].
2379
- pub trait ReplacerClosure < ' a >
2377
+ /// If a closure implements this for all `&'a Captures<'b> `, then it also
2378
+ /// implements [`Replacer`].
2379
+ pub trait ReplacerClosure < Arg >
2380
2380
where
2381
- Self : FnMut ( & ' a Captures < ' a > ) -> <Self as ReplacerClosure < ' a > >:: Output ,
2381
+ Self : FnMut ( Arg ) -> <Self as ReplacerClosure < Arg > >:: Output ,
2382
2382
{
2383
- /// Return type of the closure (may depend on lifetime `'a`).
2383
+ /// Return type of the closure (may depend on lifetime `'a` or `'b` ).
2384
2384
type Output : AsRef < str > ;
2385
2385
}
2386
- impl < ' a , F : ? Sized , O > ReplacerClosure < ' a > for F
2386
+ impl < ' a , ' b , F , O > ReplacerClosure < & ' a Captures < ' b > > for F
2387
2387
where
2388
- F : FnMut ( & ' a Captures < ' a > ) -> O ,
2388
+ F : ? Sized + FnMut ( & ' a Captures < ' b > ) -> O ,
2389
2389
O : AsRef < str > ,
2390
2390
{
2391
2391
type Output = O ;
@@ -2428,8 +2428,8 @@ use replacer_closure::*;
2428
2428
///
2429
2429
/// # Implementation by closures
2430
2430
///
2431
- /// Closures that take an argument of type `&'a Captures<'b>` for any `'a` and
2432
- /// `'b: 'a` and which return a type `T: AsRef<str>` (that may depend on `'a`
2431
+ /// Closures that take an argument of type `&'a Captures<'b>` ( for any `'a`
2432
+ /// and `'b`) and which return a type `T: AsRef<str>` (that may depend on `'a`
2433
2433
/// or `'b`) implement the `Replacer` trait through a [blanket implementation].
2434
2434
///
2435
2435
/// [blanket implementation]: Self#impl-Replacer-for-F
@@ -2575,18 +2575,18 @@ impl<'a> Replacer for &'a Cow<'a, str> {
2575
2575
/// Blanket implementation of `Replacer` for closures.
2576
2576
///
2577
2577
/// This implementation is basically the following, except that the return type
2578
- /// `T` may optionally depend on lifetime `'a`.
2578
+ /// `T` may optionally depend on the lifetimes `'a` and `'b `.
2579
2579
///
2580
2580
/// ```ignore
2581
2581
/// impl<F, T> Replacer for F
2582
2582
/// where
2583
- /// F: for<'a> FnMut(&'a Captures<'a >) -> T,
2584
- /// T: AsRef<str>, // `T` may also depend on `'a`, which cannot be expressed easily
2583
+ /// F: for<'a, 'b > FnMut(&'a Captures<'b >) -> T,
2584
+ /// T: AsRef<str>, // `T` may depend on `'a` or `'b` , which can't be expressed easily
2585
2585
/// {
2586
2586
/// /* … */
2587
2587
/// }
2588
2588
/// ```
2589
- impl < F : for < ' a > ReplacerClosure < ' a > > Replacer for F {
2589
+ impl < F : for < ' a , ' b > ReplacerClosure < & ' a Captures < ' b > > > Replacer for F {
2590
2590
fn replace_append ( & mut self , caps : & Captures < ' _ > , dst : & mut String ) {
2591
2591
dst. push_str ( ( * self ) ( caps) . as_ref ( ) ) ;
2592
2592
}
0 commit comments