Let's add an if into the mix

We can include an if statement within a match pattern, as follows:

 
fn testcode(t: u8) 
{ 
    match t 
    { 
        1 | 2 if t != 1 => println!("t was not one"), 
        1 | 2 if t != 2 => println!("t was not two"), 
        _ => println!("") 
    } 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset