-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Labels
requestRequests to resolve a particular developer problemRequests to resolve a particular developer problemstate-duplicateThis issue or pull request already existsThis issue or pull request already exists
Description
As Rust lang provided us powerful Match control flow
enum Coin {
Penny,
Nickel,
Dime,
Quarter,
}
fn value_in_cents(coin: Coin) -> u8 {
match coin {
Coin::Penny => 1,
Coin::Nickel => 5,
Coin::Dime => 10,
Coin::Quarter => 25,
}
}and
fn main() {
let x = Some(5);
let y = 10;
match x {
Some(50) => println!("Got 50"),
Some(n) if n == y => println!("Matched, n = {}", n),
_ => println!("Default case, x = {:?}", x),
}
println!("at the end: x = {:?}, y = {}", x, y);
}Would you please support Match statement ?
switch case seems not powerful than pattern matching.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
requestRequests to resolve a particular developer problemRequests to resolve a particular developer problemstate-duplicateThis issue or pull request already existsThis issue or pull request already exists