Avoid unnecessary allocation in <Value as From<Cow<'a, str>>>::from()
#405
Labels
<Value as From<Cow<'a, str>>>::from()
#405
The current implementation of
From<Cow<'a, str>>::from()
is:Now,
Cow<'a, str>::to_string()
unconditionally allocates and copies (and it has to, because it takes&self
by pointer, as dictated by theToString
trait). But sinceFrom::from
takes its argument by value, I believe it would be possible to implement it like this instead:What do you think? If it's possible and worth implementing, I'd be happy to open a PR.
The text was updated successfully, but these errors were encountered: