(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.
(See original comment: https://github.com/icerpc/slicec/pull/776/changes#r3260725518)
(See stabilization tracking issue here)
This is minor, but when we retrieve
stderrfrom aslicecplugin, we get this as aVec<u8>.To convert this to a string we have to call:
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:
This is shorter, and it avoids the copy. Instead of takes ownership of the
Vec<u8>and does the conversion in place.