tailvec-0.2.6 has been yanked.
This crate can split Vec in half, with the front part being &mut [T]
,
and the back part being able to perform push
, pop
etc
Examples
use ;
let mut vec = vec!;
vec.reserve_exact;
assert_eq!;
let = vec.split_tail;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!; // overflow of capacity
assert_eq!;
assert_eq!;
assert_eq!;
drop; // drop guard
assert_eq!;
By using this crate, you can avoid the alloc costs caused by code similar to the following
let mut vec = vec!;
vec.reserve_exact;
assert_eq!;
let a = vec.as_ptr;
let mut rest = vec.split_off;
assert_eq!;
assert_eq!;
rest.push;
rest.push;
rest.push;
rest.pop;
assert_eq!;
assert!; // allocated a new vec
assert_eq!;
vec.extend;
assert_eq!;
assert!;
Safety
- miri has passed