在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
原文:https://www.educative.io/edpresso/options-in-rust -------------------------------- The
CodeLet’s look at a case where the
fn work_experience(occupation: &str) -> Option<u32>{ match occupation{ "Junior Developer" => Some(5), "Senior Developer" => Some(10), "Project Manager" => Some(15), _ => None } } fn main() { println!("Years of work experience for a junior developer: {}", match work_experience("Junior Developer"){ Some(opt) => format!("{} years", opt), None => "0 years".to_string() }); println!("\nYears of work experience for a student: {}", match work_experience("Student"){ Some(opt) => format!("{} years", opt), None => "0 years".to_string() }); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论