diff --git a/src/regex/string.rs b/src/regex/string.rs index ee91a64a8..08eb705c7 100644 --- a/src/regex/string.rs +++ b/src/regex/string.rs @@ -2570,6 +2570,20 @@ impl<'a> Replacer for &'a Cow<'a, str> { } } +/// Blanket implementation of `Replacer` for closures. +/// +/// This implementation is basically the following, except that the return type +/// `T` may optionally depend on lifetime `'a`. +/// +/// ```ignore +/// impl Replacer for F +/// where +/// F: for<'a> FnMut(&a Captures<'_>) -> T, +/// T: AsRef, // `T` may also depend on `'a`, which cannot be expressed easily +/// { +/// /* … */ +/// } +/// ``` impl ReplacerClosure<'a>> Replacer for F { fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) { dst.push_str((*self)(caps).as_ref());