Rust 使用不稳定库功能-如何修复这些问题?
我又犯了一大堆错误:Rust 使用不稳定库功能-如何修复这些问题?,rust,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(b
$ 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();
^~~~~~~~~~
如何解决这些问题?这是什么意思:add#![功能(收集)]到板条箱属性以启用
-什么板条箱?我没有我的板条箱的源代码。那么其他人如何在他们的机器上编译我的库呢
奇怪的是,这也引发了一个错误:
src/lib.rs:1:1: 1:31 error: unstable feature
src/lib.rs:1 #![feature(convert, std_misc)]
当我将其添加到库的顶部时。我假设您使用的是Rust stable。在这种情况下,无法启用不稳定的功能 对于
Duration
可以通过将其添加到Cargo.toml中的依赖项来使用
在其他情况下,您应该能够分别使用&aaa
和&bbb
从Vec或String中获取切片。
e、 g
在持续时间内,您可以通过将时间板条箱添加到Cargo.toml中的依赖项来使用crates.io上的时间板条箱。-正如您所看到的,这就是我正在做的-->
使用std::time::duration::duration代码>哦,我不应该使用std::time::duration::duration
,对吗?但是板条箱time
是否包含std::time::duration::duration?您应该使用time::duration::duration代码>,否则您仍然在std中引用不推荐的持续时间
let b = String::from("foo"); // b is a String
let c: &str = &b; // c expects a &str; b is automatically dereferenced