Skip to content

Use from_utf8_lossy_owned for Reading from plugin stderr when Stabilized #782

@InsertCreativityHere

Description

@InsertCreativityHere

(See original comment: https://github.com/icerpc/slicec/pull/776/changes#r3260725518)
(See stabilization tracking issue here)

This is minor, but when we retrieve stderr from a slicec plugin, we get this as a Vec<u8>.
To convert this to a string we have to call:

let mut error_string = String::from_utf8_lossy(&output.stderr).into_owned();

Which is A) verbose, B) makes a copy of all of the bytes.


There is a nightly proposed function which would be a better fit:

let mut error_string = String::from_utf8_lossy_owned(output.stderr)

This is shorter, and it avoids the copy. Instead of takes ownership of the Vec<u8> and does the conversion in place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Waiting on upstreamThis Issue is on hold, waiting on some upstream dependencyeasyGood for newcomersslicecRelated to the 'slicec' crate
    No fields configured for Enhancement.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions