I want to go from a
&[u8] to a
Result<String,_>. Obviously I can use
str::from_utf8(slice).map(|s| s.to_string()), but it seems to me both of those loop over the bytes twice --- once to copy to the heap, once to check UTF8 validity.
Shouldn't there be a
String::from_utf8_slice(&[u8]) -> Result<String,_> function that copies to the heap and checks UTF8 validity with a single loop?