2 releases

Uses old Rust 2015

0.1.1 Aug 23, 2016
0.1.0 Aug 23, 2016

⚠️ Issues reported

#46 in #insert

MIT license

4KB
59 lines

insert_many

Exposes an InsertMany trait for efficiently inserting multiple items into a Vec or Vec-like struct at a time. Contains implementations for Vec and (optionally) SmallVec.

Usage

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:

Insert many optimization. Like Vec::insert, but inserts a series of items at an index rather than a single one. This can lead to significant speedup where multiple items need to be inserted.

Dependencies

~105KB