macro_rules! region_buffer {
($($element:expr),*) => { ... };
($element:expr; $len:expr) => { ... };
}Expand description
Creates a RegionBuffer containing the arguments.
region_buffer! allows RegionBuffers to be defined with the same syntax
as array expressions. There are two forms of this macro:
- Create a
RegionBuffercontaining a given list of elements:
let buf = region_buffer![1, 2, 3];
assert_eq!(*buf.get(0), 1);
assert_eq!(*buf.get(1), 2);
assert_eq!(*buf.get(2), 3);- Create a
RegionBuffergiven element and length:
let buf = region_buffer![1; 3];
assert_eq!(*buf.region(0, 3), [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, region_buffer![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.