diff options
Diffstat (limited to 'src/doc/book/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs')
-rw-r--r-- | src/doc/book/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs b/src/doc/book/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs new file mode 100644 index 000000000..8386a0ab8 --- /dev/null +++ b/src/doc/book/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs @@ -0,0 +1,12 @@ +fn main() { + let x = Some(5); + let y = 10; + + match x { + Some(50) => println!("Got 50"), + Some(n) if n == y => println!("Matched, n = {n}"), + _ => println!("Default case, x = {:?}", x), + } + + println!("at the end: x = {:?}, y = {y}", x); +} |