You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It turns out that the Replacer trait is a bit more restrictive than it should be. For the closure impl of Replacer, it requires that the closure work for all possible lifetimes. But it's far more useful to be able to provide a closure that works on a specific lifetime. This makes it possible to do things like return a Cow<str> from the closure to avoid an extra alloc.
This problem was originally brought up in #775 by @tpoliaw.
That lead to @sgrif submitting #776 that changes the Replacer trait to be parameterized over a lifetime.
Unfortunately, it's a breaking change, so this will have to wait for regex 2.0.0.
N.B. This is generally an ergonomic problem I think. It is always possible to implement Replacer oneself and do something more optimal. @tpoliaw also provided a work-around using a closure as well, although it's a bit clunky (but perhaps not as clunky as implementing Repalcer).
The text was updated successfully, but these errors were encountered:
It turns out that the
Replacer
trait is a bit more restrictive than it should be. For the closure impl ofReplacer
, it requires that the closure work for all possible lifetimes. But it's far more useful to be able to provide a closure that works on a specific lifetime. This makes it possible to do things like return aCow<str>
from the closure to avoid an extra alloc.This problem was originally brought up in #775 by @tpoliaw.
That lead to @sgrif submitting #776 that changes the
Replacer
trait to be parameterized over a lifetime.Unfortunately, it's a breaking change, so this will have to wait for
regex 2.0.0
.N.B. This is generally an ergonomic problem I think. It is always possible to implement
Replacer
oneself and do something more optimal. @tpoliaw also provided a work-around using a closure as well, although it's a bit clunky (but perhaps not as clunky as implementingRepalcer
).The text was updated successfully, but these errors were encountered: