1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
//! Introduce `if let PAT = EXPR { BODY }` construct.
//! ```rust
//! if let Some(x) = opt_val {
//! do(x);
//! } else if cond() {
//! do();
//! } else {
//! do();
//! }
//! ```
//! desugar:
//! ```rust
//! match opt_val {
//! Some(x) => {
//! do(x);
//! }
//! _ if cond() => {}
//! _ => {}
//! }
//! ```
//! # Note
//! * `else if` => `_ if guard => {}`
//! * `else` => `_ => {}`
//!
//! [RFC: 0160-if-let](https://github.com/rust-lang/rfcs/blob/master/text/0160-if-let.md)
struct RFCs(i32);