unsized-vec
Say goodbye to Vec<Box<dyn Any>>
! Cut down on your heap allocations.
UnsizedVec<T>
is like Vec<T>
, but T
can be ?Sized
.
Features
- Familiar
Vec
API. - Same time complexity as
alloc::vec::Vec
for major operations(indexing, push, pop, insert, remove).- When
T
's alignment is not known at compile time (e.g.T
is a trait object), this rule has one expection, explained in the crate docs.
- When
- For
T: Sized
,UnsizedVec<T>
compiles to a newtype aroundalloc::vec::Vec
, and can be trivially converted to/from it. - For unsized
T
, there are two heap allocations: one for the elements, and one for the pointer metadata. #[no_std]
(but requiresalloc
).
Drawbacks
- Invariant in
T
. - Experimental, nightly-only.
Example
use Debug;
use box_new_with;
use ;
License
unsized-vec
is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.