unsized-vec

docs.rs Crates.io

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

Drawbacks

Example

```rust

![feature(unsizedfnparams)]

use core::fmt::Debug;

use emplacable::boxnewwith; use unsizedvec::{unsizevec, UnsizedVec};

fn main() { let mut vec: UnsizedVec = unsizevec![27.53f32, "oh the places we'll go", Some(())];

for traitobj in &vec {
    dbg!(traitobj);
};

assert_eq!(vec.len(), 3);

let maybe_popped: Option<Box<dyn Debug>> = vec.pop_into().map(box_new_with);
let popped = maybe_popped.unwrap();
dbg!(&*popped);

assert_eq!(vec.len(), 2);

} ```

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.