rust filling a vector code example
Example: rust filling a vector
// Several equivalent examples
fn arr(n: usize) -> Vec<u32> {
(0 .. n as u32).collect()
}
fn arr(n: usize) -> Vec<u32> {
let vec_n: Vec<u32> = (0..n as u32).collect();
vec_n
}
fn arr(n: usize) -> Vec<u32> {
let mut vec_n: Vec<u32> = Vec::new();
for x in 0..n {
vec_n.push(x as u32);
}
res
}