encoding_rs
encoding_rs copied to clipboard
Allow passing `String` to `Encoding::encode`
In the common case when converting from UTF8 to UTF8, or the string is all ASCII, this avoids an
extra heap allocation for the caller if they only have a String
available.
Previously, they would have to call encoding.encode(&string).into_owned()
to avoid lifetime errors.
This change is backwards compatible.