5 rust
我又遇到了很多错误:
$ cargo build
error: use of unstable library feature 'std_misc'
use std::time::duration::Duration;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: use of unstable library feature 'convert': waiting on RFC revision
let my_let1 = aaa(bbb.as_str(), ccc, ddd.eee);
^~~~~~~~
error: use of unstable library feature 'convert': waiting on RFC revision
let let1 = aaa.as_slice();
^~~~~~~~~~
error: use of unstable library feature 'convert': waiting on RFC revision
let let1 = str::from_utf8(aaa.as_slice()).unwrap();
^~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
如何解决?这是什么意思:add #![feature(collections)] to the crate attributes to enable-什么板条箱?我没有板条箱的源代码。那么其他人将如何在他们的计算机上编译我的库?
奇怪的是,这还会引发错误:
src/lib.rs:1:1: 1:31 error: unstable feature
src/lib.rs:1 #![feature(convert, std_misc)]
Run Code Online (Sandbox Code Playgroud)
当我将其添加到库的顶部时。
我假设您使用的是 Rust stable。在这种情况下,无法启用不稳定的功能。
您可以通过将crates.io 上的时间箱添加到 Cargo.toml 的依赖项中来Duration使用它。
在其他情况下,您应该能够简单地分别使用&aaa和&bbb来从 Vec 或 String 中获取切片。例如
let b = String::from("foo"); // b is a String
let c: &str = &b; // c expects a &str; b is automatically dereferenced
Run Code Online (Sandbox Code Playgroud)