Answers for "vector in rust"

2

vector in rust

//To create a new, empty vector

fn main() {
    let v: Vec<i32> = Vec::new();
}

//vector that holds the values you give it.

fn main() {
    let v = vec![1, 2, 3];
}
Posted by: Guest on September-07-2021
1

rust empty vector

let mut vec = Vec::new();
Posted by: Guest on September-09-2020
1

push and item to vector rust

let mut vec = vec![10];
vec.push(100);
assert_eq!(vec[1], 100);
Posted by: Guest on October-14-2020

Browse Popular Code Answers by Language