]> git.proxmox.com Git - rustc.git/blob - src/doc/book/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / doc / book / listings / ch18-patterns-and-matching / listing-18-01 / src / main.rs
1 fn main() {
2 let favorite_color: Option<&str> = None;
3 let is_tuesday = false;
4 let age: Result<u8, _> = "34".parse();
5
6 if let Some(color) = favorite_color {
7 println!("Using your favorite color, {color}, as the background");
8 } else if is_tuesday {
9 println!("Tuesday is green day!");
10 } else if let Ok(age) = age {
11 if age > 30 {
12 println!("Using purple as the background color");
13 } else {
14 println!("Using orange as the background color");
15 }
16 } else {
17 println!("Using blue as the background color");
18 }
19 }