【发布时间】:2017-10-30 04:07:45
【问题描述】:
我有以下代码:
#[cfg(all(feature = "unstable", unique))]
#[cfg(all(feature = "unstable", heap_api))]
#[cfg(all(feature = "unstable", alloc))]
use std::ptr::Unique;
use std::mem;
use alloc::heap;
pub struct Foo<T> {
arr: Unique<T>,
cap: usize,
probe_limit: usize,
}
但是,当我尝试使用 cargo build --features "unstable" 编译它时,我得到一个编译错误。请注意,我使用的是 Rust 的夜间版本,并且不稳定的功能设置正确(否则我会得到不同的错误)。
error[E0412]: cannot find type `Unique` in this scope
--> src/hash/arr.rs:27:8
|
27 | arr: Unique<T>,
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
| use std::ptr::Unique;
我不确定为什么找不到Unique。我应该在我的文件顶部使用它。 use ::std::ptr::Unique 不起作用。
【问题讨论】: