Struct konst::alloc_type::VEC_NEW [−][src]
pub struct VEC_NEW<T>(_);
This is supported on crate feature
alloc
only.Expand description
An empty Vec<T>
. Usable to construct a [Vec<T>; N]
.
As of Rust 1.51.0, [Vec::new(); LEN]
is not valid,
because Vec<T>
isn’t copy,
but [CONST; LEN]
does work, like in the example below.
Example
use konst::alloc_type::VEC_NEW;
use std::borrow::Cow;
const VECS: [Vec<u64>; 3] = [VEC_NEW::<u64>::V; 3];
let mut vecs = VECS;
vecs[0].extend_from_slice(&[3]);
vecs[1].extend_from_slice(&[5, 8]);
vecs[2].extend_from_slice(&[13, 21, 34]);
assert_eq!(vecs, [&[3][..], &[5, 8], &[13, 21, 34]]);