【发布时间】:2020-07-14 14:53:44
【问题描述】:
我目前正在通过构建一个简单的工具来学习 rust。
我需要连接一些脚本并使用 rust-embed。 crate 为给定文件返回一个借用的 &[u8],我需要将其解释为字符串。
来自锈documentation, 我有以下example。
#![allow(unused)]
fn main() {
use std::str;
// some bytes, in a vector
let sparkle_heart = vec![240, 159, 146, 150];
// We know these bytes are valid, so just use `unwrap()`.
let sparkle_heart = str::from_utf8(&sparkle_heart).unwrap();
println!("I {:?} U", &sparkle_heart);
}
输出是
I "????" U
我的问题是围绕心脏的引用,这导致我的最终脚本出现问题。
【问题讨论】: