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