Macro thincollections::v64

source ·
macro_rules! v64 {
    (@one $x:expr) => { ... };
    ($elem:expr; $n:expr) => { ... };
    ($($x:expr),*$(,)*) => { ... };
}
Expand description

Creates a [V64] containing the arguments.

v64! allows V64s to be defined with the same syntax as array expressions. There are two forms of this macro:

  • Create a [V64] containing a given list of elements:
let v: V64<i32> = v64![1, 2, 3];
assert_eq!(v[0], 1);
assert_eq!(v[1], 2);
assert_eq!(v[2], 3);
  • Create a [V64] from a given element and size:
let v: V64<u64> = v64![1; 3];
assert_eq!(3, v.len());
// assert_eq!(v, V64::from_buf([1, 1, 1]));

Note that unlike array expressions this syntax supports all elements which implement Clone and the number of elements doesn’t have to be a constant.

This will use clone to duplicate an expression, so one should be careful using this with types having a nonstandard Clone implementation. For example, v64![Rc::new(1); 5] will create a vector of five references to the same boxed integer value, not five references pointing to independently boxed integers.