2个版本
使用旧的Rust 2015
0.1.1 | 2016年8月23日 |
---|---|
0.1.0 | 2016年8月23日 |
#46 在 #insert
4KB
59 行
insert_many
公开了一个 InsertMany
trait,用于高效地向 Vec
或类似 Vec
的结构中一次插入多个项。包含对 Vec
和(可选)SmallVec
的实现。
用法
extern crate insert_many;
use insert_many::InsertMany;
fn main() {
let mut v = vec![1, 2, 3];
// `insert_many` accepts any `ExactSizeIterator` with the same item type.
// it will panic if given a bad `ExactSizeIterator` impl.
v.insert_many(0, [1, 1].iter().cloned();
v.insert_many(4, vec![2, 2]);
v.insert_many(6, [3, 3].iter().cloned());
assert_eq!(v, vec![1, 1, 1, 2, 2, 2, 3, 3, 3]);
}
lib.rs
:
多个插入优化。类似于 Vec::insert
,但是在一组索引中插入一系列项而不是单个项。在需要插入多个项的情况下,这可以显著提高速度。
依赖项
~105KB