encoding_rs icon indicating copy to clipboard operation
encoding_rs copied to clipboard

Allow passing `String` to `Encoding::encode`

Open jyn514 opened this issue 2 years ago • 0 comments

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.

jyn514 avatar Dec 22 '21 19:12 jyn514