Rust中的Vector類型

經常使用類型操做,python

如python中的list,turple,dictory等,編程

更方常編程經常使用數據的處理。spa

fn main() {
    let v = vec![1, 2, 3, 4, 5];
    
    let third: &i32 = &v[2];
    println!("The third element is {}", third);

    match v.get(2) {
    Some(third) => println!("The element is {}", third),
        None => println!("There is no element"),
    }

    match v.get(20) {
        Some(twenty) => println!("The element is {}", twenty),
        None => println!("There is no element"),
    }

}

相關文章
相關標籤/搜索