collections::dlist::DList
希望实施collections::Deque
,其中push_back
方法。
但是编译这个简单的程序:
extern crate collections;
fn main () {
let mut c : collections::dlist::DList<int> = collections::dlist::DList::new();
c.push_back(1);
}
给出了这个错误消息
try.rs:5:4: 5:16 error: type `collections::dlist::DList<int>` does not implement any method in scope named `push_back`
try.rs:5 c.push_back(1);
^~~~~~~~~~~~
答案 0 :(得分:4)
必须导入特征才能使其方法可用。这也在文档中注明:
DList实现特质Deque。它应该与
use collections::Deque
一起导入。