mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-24 05:13:29 +08:00
20 lines
600 B
Rust
20 lines
600 B
Rust
fn main() {
|
|
let favorite_color: Option<&str> = None;
|
|
let is_tuesday = false;
|
|
let age: Result<u8, _> = "34".parse();
|
|
|
|
if let Some(color) = favorite_color {
|
|
println!("Using your favorite color, {color}, as the background");
|
|
} else if is_tuesday {
|
|
println!("Tuesday is green day!");
|
|
} else if let Ok(age) = age {
|
|
if age > 30 {
|
|
println!("Using purple as the background color");
|
|
} else {
|
|
println!("Using orange as the background color");
|
|
}
|
|
} else {
|
|
println!("Using blue as the background color");
|
|
}
|
|
}
|