insert_many 0.1.1

insert_many optimization for vec-like structures
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 5.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • rphmeier/insert_many
    0 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rphmeier

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]);
}