From a byte array, I want to convert a slice to a string using the ASCII-encoding. The solution
fn main() {
let buffer: [u8; 9] = [255, 255, 255, 255, 77, 80, 81, 82, 83];
let s = String::from_iter(buffer[5..9].iter().map(|v| { *v as char }));
println!("{}", s);
assert_eq!("PQRS", s);
}
does not seem to be idiomatic, and has a smell of poor performance. Can we do better? Without external crates?