[−][src]Macro col_macros::vector
Construct or update a vector of type Vector<T> which can be and is an alias to Vec
Collections with the with_capacity and set_len methods that deref to [T] are accepted.
Why not vec!?
-
Does not take in account where the input is an identifier or literal and does not apply optimizations based on that.
-
It is not general purpose,it always construct a Vec
.
Examples
#![feature(proc_macro_hygiene)] use col_macros::vector; use col_macros::types::Vector; let mut vec1: Vec<usize> = vector![1, 2, 3]; let eight: usize = 8; assert_eq!(vec1, vec![1, 2, 3]); vector![for &mut vec1, ins 4, 5, 6, eight].push(7); // we still have a mutable reference assert_eq!(vec1, vector![1, 2, 3, 4, 5, 6, eight, 7]); assert_eq!(vec![eight; 8], vector![eight; eight]); assert_eq!(vec![8, 8, 8], vector![eight, eight, eight]); assert_eq!(vec![8, 8, 8], vector![eight, eight, 8]);