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]]);

Implementations

The value that this constructs.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.