gw-rust-programming-tutorial 0.1.0

gw rust test.
Documentation
pub fn test_vec() {
    let v: Vec<i32> = Vec::new();

    //使用宏
    let v = vec![1, 2, 3];

    let mut v = Vec::new();

    v.push(5);
    v.push(6);
    v.push(7);
    v.push(8);

    println!("vec={:?}", v);

    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 third element is {}", third),
        None => println!("There is no third element."),
    }

    //遍历赋值
    let mut v = vec![100, 32, 57];
    for i in &mut v {
        *i += 50;
    }
    println!("遍历赋值后 vec={:?}", v);

    //使用枚举存放多种类型
    #[derive(Debug)]
    enum SpreadsheetCell {
        Int(i32),
        Float(f64),
        Text(String),
    }

    let row = vec![
        SpreadsheetCell::Int(3),
        SpreadsheetCell::Text(String::from("blue")),
        SpreadsheetCell::Float(10.12),
    ];

    println!("enum row={:?}", row);
}