2.3.0 |
|
---|---|
2.2.1 |
|
1.5.1 |
|
1.5.0 |
|
在 #linked-list 中排名 118
每月下载量 26 次
56KB
1K SLoC
lists
包含各种顺序数据结构实现的库。
测试
$ cd lists
$ cargo test
...
# If things go well during the tests you should see `ok` as the test result.
示例
DoublyLinkedList
总和
use lists::dl_list;
/// Creates a new `DoublyLinkedList`, and then adds all elements together into a sum.
fn main() {
let list = dl_list![1, 2, 3, 4, 5];
let sum = list.into_iter().sum::<i32>();
assert_eq!(sum, 15);
}
SinglyLinkedList
总和
use lists::sl_list;
/// Creates a new `SinglyLinkedList`, and then adds all elements together into a sum.
fn main() {
let list = sl_list![1, 2, 3, 4, 5];
let sum = list.into_iter().sum::<i32>();
assert_eq!(sum, 15);
}