to_string() 的稳定替代方案是什么

What is the stable alternative of to_string()

我正在努力完成 rust book。在字符串章节中,许多示例使用 to_string() 我的编译器版本(rustc 1.0.0-dev)给出以下警告

strings.rs:3:23: 3:34 warning: use of unstable item, #[warn(unstable)] on by default
strings.rs:3   let mut s = "Hello".to_string();

代码:

fn main() {
  let mut s = "Hello".to_string();
  println!("{}", s);
}

我从了解到这是因为API可能会改变,但我想知道如果我想转换字符串切片(str&)我应该使用什么到一个字符串

您可以解决这些问题,例如format!("Hello"),但我暂时不会打扰。