unsized-vec
UnsizedVec<T>
is like Vec<T>
, but T
can be ?Sized
.
Vec
.Vec
for indexing, push, pop, insert, remove (more or less)
T
's alignment isn't fixed at compile-time,
adding a new element to the Vec
with a greater alignment than all elements currently present
will take $\mathcal{O}(n)$ time, and will most likely reallocate.T: Sized
, only one heap allocation, approximately same memory layout as Vec
.T
, two heap allocations (one for the elements, one for the pointer metadata).#[no_std]
(but requires alloc
).```rust
use core::fmt::Debug; use unsizedvec::{*, emplace::boxnew_with};
// Box::new()
necessary only to coerce the values to trait objects.
let obj: Box
assert_eq!(vec.len(), 2);
let popped = boxnewwith(|e| vec.pop_unwrap(e)); dbg!(&*popped);
assert_eq!(vec.len(), 1); ```