Crates.io | list_tools |
lib.rs | list_tools |
version | 0.1.9-features |
source | src |
created_at | 2024-01-29 04:58:58.03657 |
updated_at | 2024-04-20 07:24:54.816111 |
description | 一个自己研发的Vec |
homepage | |
repository | |
max_upload_size | |
id | 1118386 |
size | 32,777 |
[List
]是一个基于“struct递归”的结构体,他由于不基于Rust
自带的[Vec
],所以作者得从零搭建:)。
有不好的地方可以自己写(VSCode里Ctrl+左键)。放心,协议是GPL-3.0
已发布:
crate地址:https://crates.io/crates/list_tools
gitee地址:https://gitee.com/yizili/list_tools/edit/master
use list_tools::*;
let mut l: List<u8> = clist!(1, 1, 2, 4);
let _ = l.remove_of_index(0);
l.append_of_end(5);
l.append_of_front(0);
l.append_of_index(3, 3);
if Vec::from(l.clone()) == vec![0, 1, 2, 3, 4, 5]
&& Vec::from(l.clone()).to_list() == clist!(0, 1, 2, 3, 4, 5)
{
println!("oh yea");
}
assert_eq!(l.get_t_of_index(0).unwrap(), &0);
assert_eq!(l.get_t_of_index(1).unwrap(), &1);
assert_eq!(l.get_t_of_index(2).unwrap(), &2);
assert_eq!(&l, &clist!(0, 1, 2, 3, 4, 5));
assert_ne!(&l, &clist!());
println!("{}", l);
println!("{:?}", l);
println!("{:#?}", l);
// --snip--
println!("---snip---");
let mut l = clist!(0; 10);
assert_eq!(l, clist!(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
println!("{}", l);
println!("{:?}", l);
println!("{:#?}", l);
assert_eq!(l.reverse(), clist!(0; 10));
l.clear();
assert_eq!(l, List::new());
// --snip--
println!("---snip---");
let l = clist!(1, 2, 3, 4, 5);
assert_eq!(l[0], *l.get_t_of_index(0).unwrap());
反馈发邮箱:3396311242@qq.com