将 &[u8] 转换为字符串

Qwe*_*tie 6 types rust

我有一个字节数组,我想将其返回为std::string::String. 我发现的其他答案和文档是将 Vectors 转换为字符串。

我如何将字节数组转换&[u8]为 a String

Tim*_*ann 7

它正在与std::str::from_utf8

std::str::from_utf8(byte_array).unwrap().to_string();
Run Code Online (Sandbox Code Playgroud)

操场