Answers for "remove elements from vector rust"

1

remove an element from vector rust

fn main() {

    let mut num = vec![10, 20, 30, 40, 50];

    // remove [2] (30)
    num.remove(2);

    println!("num[0]: {}", num[0]);
    println!("num[1]: {}", num[1]);
    println!("num[2]: {}", num[2]);
    println!("num[3]: {}", num[3]);

}
Posted by: Guest on October-12-2021

Code answers related to "remove elements from vector rust"

Browse Popular Code Answers by Language