使用不稳定的库功能 - 我该如何解决这些问题? [英] use of unstable library feature - how can I fix those?

查看:30
本文介绍了使用不稳定的库功能 - 我该如何解决这些问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我又犯了一堆错误:

$ 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 - 什么箱子?我没有我的箱子的源代码.那么其他人将如何在他们的机器上编译我的库?

How to solve them? What does it mean: add #![feature(collections)] to the crate attributes to enable - what crates? I don't have the source code of my crates. How would other people compile my library on their machines then?

奇怪的是,这也会引发错误:

And oddly enough this also throws an error:

src/lib.rs:1:1: 1:31 error: unstable feature
src/lib.rs:1 #![feature(convert, std_misc)]

当我将它添加到我的库顶部时.

when I add it at the top my library.

推荐答案

我假设您使用的是稳定版 Rust.在这种情况下,无法启用不稳定的功能.

I'm assuming you're using Rust stable. In that case unstable features can't be enabled.

对于 Duration,您可以使用 crates.io 上的时间箱将其添加到 Cargo.toml 中的依赖项中.

For Duration you can use the time crate on crates.io by adding it to the dependencies in your Cargo.toml.

在其他情况下,您应该能够分别使用 &aaa&bbb 从 Vec 或 String 中获取切片.例如

In the other cases, you should be able to simply use &aaa and &bbb respectively to get slices out of Vec or String. e.g.

let b = String::from("foo"); // b is a String
let c: &str = &b; // c expects a &str; b is automatically dereferenced

这篇关于使用不稳定的库功能 - 我该如何解决这些问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆