码迷,mamicode.com
首页 > 其他好文 > 详细

Rust中的Vector类型

时间:2019-08-24 19:09:34      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:mamicode   element   img   操作   HERE   print   color   pre   常用类   

常用类型操作,

如python中的list,turple,dictory等,

更方常编程常用数据的处理。

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"),
    }

}

技术图片

Rust中的Vector类型

标签:mamicode   element   img   操作   HERE   print   color   pre   常用类   

原文地址:https://www.cnblogs.com/aguncn/p/11405307.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!