pub fn match_usage(){
    let fruits = vec!["banana", "apple", "coconut", "orange", "strawberry"];
    for &index in [0, 2, 99].iter() {
        match fruits.get(index) {
            Some(fruit_name) => println!("It's a delicious {}!", fruit_name),
            None => println!("There is no fruit! :("),
        }
    }

    /*
        In the preceding code, we iterate through the same indexes from our
        previous example (0, 2, and 99) and then use each one to retrieve a
        value from the fruits vector by using the fruits.get(index)
        expression.

        Because the fruits vector contains &str elements, we know that the
        result of this expression is of type Option<&str>. You then use a
        match expression against the Option value and define a course of
        action for each of its variants. Rust refers to those branches as
        match arms, and each arm can handle one possible outcome for the
        matched value.
    */
}
/*
    Rust has an extremely powerful control flow operator called match, which
    you can use to compare a value against a series of patterns and then
    execute code based on which pattern matches.
*/
Rust has an extremely powerful control flow operator called match, which
you can use to compare a value against a series of patterns and then
execute code based on which pattern matches.
Rust has an extremely powerful control flow operator called match which you can use to compare a value against a series of patterns and then execute code based on which pattern matches .
pub fn match_usage(){
    let fruits = vec!["banana", "apple", "coconut", "orange", "strawberry"];
    for &index in [0, 2, 99].iter() {
        match fruits.get(index) {
            Some(fruit_name) => println!("It's a delicious {}!", fruit_name),
            None => println!("There is no fruit! :("),
        }
    }
    /*
        In the preceding code, we iterate through the same indexes from our
        previous example (0, 2, and 99) and then use each one to retrieve a
        value from the fruits vector by using the fruits.get(index)
        expression.
        Because the fruits vector contains &str elements, we know that the
        result of this expression is of type Option<&str>. You then use a
        match expression against the Option value and define a course of
        action for each of its variants. Rust refers to those branches as
        match arms, and each arm can handle one possible outcome for the
        matched value.
    */
}
pub fn match_usage ( ) { let fruits = vec ! [ " " " " " " " " " " ] ; for & index in [ 0 , 2 , 99 ] . iter ( ) { match fruits . get ( index ) { Some ( fruit_name ) => println ! ( " " fruit_name ) , None => println ! ( " " ) , } } /*
        In the preceding code, we iterate through the same indexes from our
        previous example (0, 2, and 99) and then use each one to retrieve a
        value from the fruits vector by using the fruits.get(index)
        expression.

        Because the fruits vector contains &str elements, we know that the
        result of this expression is of type Option<&str>. You then use a
        match expression against the Option value and define a course of
        action for each of its variants. Rust refers to those branches as
        match arms, and each arm can handle one possible outcome for the
        matched value.
    */ }
Rust has an extremely powerful control flow operator called match, which
you can use to compare a value against a series of patterns and then
execute code based on which pattern matches.
Rust has an extremely powerful control flow operator called match which you can use to compare a value against a series of patterns and then execute code based on which pattern matches .