2015-06-22 55 views
4

我又站了一堆错误:使用不稳定的库功能 - 我该如何解决这些问题?

$ 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 #![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)] 

,当我在上面我的库添加它。

回答

3

我假设你正在使用Rust stable。在这种情况下,不稳定的功能无法启用。

对于Duration,您可以使用time crate on crates.io将其添加到Cargo.toml中的依赖关系中。

在其他情况下,您应该能够分别简单地使用&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 
+0

**对于持续时间,你可以将它添加到您的Cargo.toml依赖使用上crates.io时间箱子** - 这是我在做什么,你可以看到 - >'使用std :: time :: duration :: Duration;' –

+0

哦,我不应该使用'std :: time :: duration :: Duration',对吧?但不包括'时间'包含std :: time :: duration :: Duration? –

+0

你应该'使用time :: duration :: Duration;',否则你仍然引用std –

相关问题