gpt4 book ai didi

Rust DList 实现双端队列?

转载 作者:行者123 更新时间:2023-11-29 08:24:09 30 4
gpt4 key购买 nike

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);
^~~~~~~~~~~~

最佳答案

必须导入特征才能使其方法可用。文档中也指出了这一点:

DList implements the trait Deque. It should be imported with use collections::Deque.

关于Rust DList 实现双端队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24725506/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com