fn match_guards() {
    let num = Some(4);

    match num {
        Some(x) if x < 5 => println!("match_guards: num less than five: {}", x),
        Some(x) => println!("match_guards: num {}", x),
        None => (),
    }    

    let x = Some(5);
    let y = 10;

    match x {
        Some(50) => println!("match_guards: Got 50"),
        Some(n) if n == y => println!("match_guards: Matched, n = {:?}", n),
        _ => println!("match_guards: Default case, x = {:?}", x),
    }

    println!("match_guards: at the end: x = {:?}, y = {:?}", x, y);

    let x = 4;
    let y = false;

    match x {
        /*
        The match condition states that the arm only matches if the value of x 
        is equal to 4, 5, or 6 and if y is true.
        */
        4 | 5 | 6 if y => println!("match_guards: 4, 5, or 6? yes"),
        _ => println!("match_guards: 4, 5, or 6? no"),
    }
}
/*
A match guard is an additional if condition specified after the pattern in a 
match arm that must also match, along with the pattern matching, for that arm to 
be chosen. 
*/
A match guard is an additional if condition specified after the pattern in a
match arm that must also match, along with the pattern matching, for that arm to
be chosen.
A match guard is an additional if condition specified after the pattern in a match arm that must also match along with the pattern matching for that arm to be chosen .
fn match_guards() {
    let num = Some(4);
    match num {
        Some(x) if x < 5 => println!("match_guards: num less than five: {}", x),
        Some(x) => println!("match_guards: num {}", x),
        None => (),
    }    
    let x = Some(5);
    let y = 10;
    match x {
        Some(50) => println!("match_guards: Got 50"),
        Some(n) if n == y => println!("match_guards: Matched, n = {:?}", n),
        _ => println!("match_guards: Default case, x = {:?}", x),
    }
    println!("match_guards: at the end: x = {:?}, y = {:?}", x, y);
    let x = 4;
    let y = false;
    match x {
        /*
        The match condition states that the arm only matches if the value of x 
        is equal to 4, 5, or 6 and if y is true.
        */
        4 | 5 | 6 if y => println!("match_guards: 4, 5, or 6? yes"),
        _ => println!("match_guards: 4, 5, or 6? no"),
    }
}
fn match_guards ( ) { let num = Some ( 4 ) ; match num { Some ( x ) if x < 5 => println ! ( " " x ) , Some ( x ) => println ! ( " " x ) , None => ( ) , } let x = Some ( 5 ) ; let y = 10 ; match x { Some ( 50 ) => println ! ( " " ) , Some ( n ) if n == y => println ! ( " " n ) , _ => println ! ( " " x ) , } println ! ( " " x y ) ; let x = 4 ; let y = false ; match x { /*
        The match condition states that the arm only matches if the value of x 
        is equal to 4, 5, or 6 and if y is true.
        */ 4 | 5 | 6 if y => println ! ( " " ) , _ => println ! ( " " ) , } }
A match guard is an additional if condition specified after the pattern in a
match arm that must also match, along with the pattern matching, for that arm to
be chosen.
A match guard is an additional if condition specified after the pattern in a match arm that must also match along with the pattern matching for that arm to be chosen .