@@ -2376,16 +2376,21 @@ mod replacer_closure {
2376
2376
use super :: * ;
2377
2377
/// If a closure implements this for all `'a`, then it also implements
2378
2378
/// [`Replacer`].
2379
+ // TODO: Use two lifetimes `'a` and `'b`: one for the reference and one for
2380
+ // the lifetime argument `'b` of `Captures<'b>`. This requires a syntax
2381
+ // like `for<'a, 'b: 'a> ReplacerClosure<'a, 'b> when using this trait,
2382
+ // which currently doesn't exist.
2383
+ // See also: https://github.com/rust-lang/rfcs/pull/3261
2379
2384
pub trait ReplacerClosure < ' a >
2380
2385
where
2381
- Self : FnMut ( & ' a Captures < ' a > ) -> <Self as ReplacerClosure < ' a > >:: Output ,
2386
+ Self : FnMut ( & ' a Captures < ' _ > ) -> <Self as ReplacerClosure < ' a > >:: Output ,
2382
2387
{
2383
2388
/// Return type of the closure (may depend on lifetime `'a`).
2384
2389
type Output : AsRef < str > ;
2385
2390
}
2386
2391
impl < ' a , F : ?Sized , O > ReplacerClosure < ' a > for F
2387
2392
where
2388
- F : FnMut ( & ' a Captures < ' a > ) -> O ,
2393
+ F : FnMut ( & ' a Captures < ' _ > ) -> O ,
2389
2394
O : AsRef < str > ,
2390
2395
{
2391
2396
type Output = O ;
@@ -2430,7 +2435,8 @@ use replacer_closure::*;
2430
2435
///
2431
2436
/// Closures that take an argument of type `&'a Captures<'b>` for any `'a` and
2432
2437
/// `'b: 'a` and which return a type `T: AsRef<str>` (that may depend on `'a`
2433
- /// or `'b`) implement the `Replacer` trait through a [blanket implementation].
2438
+ /// but not on `'b`) implement the `Replacer` trait through a [blanket
2439
+ /// implementation].
2434
2440
///
2435
2441
/// [blanket implementation]: Self#impl-Replacer-for-F
2436
2442
///
@@ -2580,7 +2586,7 @@ impl<'a> Replacer for &'a Cow<'a, str> {
2580
2586
/// ```ignore
2581
2587
/// impl<F, T> Replacer for F
2582
2588
/// where
2583
- /// F: for<'a> FnMut(&'a Captures<'a >) -> T,
2589
+ /// F: for<'a, 'b > FnMut(&'a Captures<'b >) -> T,
2584
2590
/// T: AsRef<str>, // `T` may also depend on `'a`, which cannot be expressed easily
2585
2591
/// {
2586
2592
/// /* … */
0 commit comments