diff --git a/src/doc/reference.md b/src/doc/reference.md index 5a445bb42a6b2..66a7f543ad95f 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3072,6 +3072,20 @@ of a condition expression it expects a refutable let statement. If the value of expression on the right hand side of the let statement matches the pattern, the corresponding block will execute, otherwise flow proceeds to the first `else` block that follows. +``` +let dish = ("Ham", "Eggs"); + +// this body will be skipped because the pattern is refuted +if let ("Bacon", b) = dish { + println!("Bacon is served with {}", b); +} + +// this body will execute +if let ("Ham", b) = dish { + println!("Ham is served with {}", b); +} +``` + ### While let loops A `while let` loop is semantically identical to a `while` loop but in place of a