这是我的代码:
let mut altbuf: Vec<u8> = Vec::new();
// Stuff here...
match stream.read_byte() {
Ok(d) => altbuf.push(d),
Err(e) => { println!("Error: {}", e); doneflag = true; }
}
for x in altbuf.iter() {
println!("{}", x);
}
Run Code Online (Sandbox Code Playgroud)
代码打印u8字节是正确的,但我无法弄清楚如何将纯u8字节的矢量转换为字符串?对堆栈溢出的类似问题的唯一其他答案假定您正在使用类型为&[u8]的向量.
rust ×1