[][src]Macro col_macros::vector

macro_rules! vector {
    (for $map:expr, ins $( $k:expr ),*) => { ... };
    (for $map:tt, ins $( $k:tt ,)*) => { ... };
    ( $( $k:expr ),*) => { ... };
    (for $map:expr, ins $e:expr; $n:expr) => { ... };
    ( $e:expr; $n:expr) => { ... };
    ( $( $k:tt ,)*) => { ... };
}

Construct or update a vector of type Vector<T> which can be and is an alias to Vec in the types module.

It does so by simply creating an array from the elements,set the capacity of the vec at they length,read each entry into and mem::forget the array.

Collections with a capacity and the push method are accepted,like BinaryHeap.

Examples

use col_macros::vector;
use col_macros::types::Vector;
 
let mut vec: Vec<u32> = vector![1, 2, 3];
 
assert_eq!(vec, vec![1, 2, 3]);
 
vector![for &mut vec, ins 4, 5, 6].push(7); // we still have a mutable reference 
 
assert_eq!(vec, vector![1, 2, 3, 4, 5, 6, 7]);
 
assert_eq!(vec![0; 8], vector![0; 8]);