Something like let v = vec![1, 2, 3]; would default to i32 but I would like to specify the type as u8.
One alternate is to create with:
let v: Vec<u8> = vec![1, 2, 3];
or
let v: Vec<u8> = Vec::new();
v.push(1);
v.push(2);
v.push(3);
Is there a better way to directly use the macro? In both cases, I need to declare a variable.
Sometimes, I need to use the vector in an assert statement. If there was a way to avoid creating the variable, I could have written:
pub fn func1() -> &[u8] {
// return slice [1, 2, 3] of [u8];
}
assert_eq!(vec![1, 2, 3], func1());