chunked_vec

Macro chunked_vec 

Source
macro_rules! chunked_vec {
    () => { ... };
    ($elem:expr; $n:expr) => { ... };
    ($($x:expr),+ $(,)?) => { ... };
}
Expand description

Creates a new [ChunkedVec] using a syntax similar to the standard vec! macro.

This macro provides two main ways to create a ChunkedVec:

§Creating from a list of elements

let vec = chunked_vec![1, 2, 3];
assert_eq!(vec[0], 1);
assert_eq!(vec[1], 2);
assert_eq!(vec[2], 3);

§Creating with repeated elements

let vec = chunked_vec![1; 3];
assert_eq!(vec[0], 1);
assert_eq!(vec[1], 1);
assert_eq!(vec[2], 1);

§Empty vector

use chunked_vec::ChunkedVec;
let vec:ChunkedVec<i32> = chunked_vec![];
assert_eq!(vec.len(), 0);

§Notes

  • Like the standard vec! macro, this macro works with any type that implements Clone
  • When using chunked_vec![elem; n] syntax, the element will be cloned n times
  • Trailing commas are supported in the list syntax