fn main(){ enum Sprean{ Int(i32), Float(f64), Text(String), }
let row=vec![
Sprean::Int(3),
Sprean::Float(10.12),
Sprean::Text(String::from("blue")),
];
println!("This is your {}",row[0]);
}
1
共 11 条评论, 1 页
评论区
写评论也可以用这种方法
也可以用这种方法
#[derive(Debug)] enum Sprean { Int(i32), Float(f64), Text(String), } fn main() { let row = vec![ Sprean::Int(3), Sprean::Float(10.12), Sprean::Text(String::from("blue")), ];
}
还有可以使用match
Thanks♪(・ω・)ノ
Thanks♪(・ω・)ノ
#[derive(Debug)] enum Sprean { Int(i32), Float(f64), Text(String), } fn main() { let row=vec![ Sprean::Int(3), Sprean::Float(10.12), Sprean::Text(String::from("blue")), ]; println!("This is your {:?}",row[0]); }
run了一下上面的,有点问题,发一个可以run的
#[derive(Debug)] enum Sprean { Int(i32), Float(f64), Text(String), } fn main() { let row=vec![ Sprean::Int(3), Sprean::Float(10.12), Sprean::Text(String::from("blue")), ]; println!("This is your {:?}",row[0]); }
run了一下上面的,有点问题,发一个可以run的
#[derive(Debug)] enum Sprean{ Int(i32), Float(f64), Text(String), } fn main() { let row=vec![ Sprean::Int(3), Sprean::Float(10.12), Sprean::Text(String::from("blue")), ]; println!("This is your {:?}",row[0]); }
run了一下上面的,有点问题,发一个可以run的
#[derive(Debug)] enum Sprean{ Int(i32), Float(f64), Text(String), }
fn main() { let row=vec![ Sprean::Int(3), Sprean::Float(10.12), Sprean::Text(String::from("blue")), ];
}
run了一下上面的,有点问题,发一个可以run的
#[derive(Debug)] enum Sprean{ Int(i32), Float(f64), Text(String), }
fn main() { let row=vec![ Sprean::Int(3), Sprean::Float(10.12), Sprean::Text(String::from("blue")), ];
println!("This is your {:?}",row[0]); }