Rust Match Statement

[Solved] Rust Match Statement | Rust - Code Explorer | yomemimo.com
Question : rust match string

Answered by : badname

match stringthing.as_str() { "a" => println!("0"), "b" => println!("1"), "c" => println!("2"), _ => println!("something else!"),
}

Source : https://stackoverflow.com/questions/25383488/how-to-match-a-string-against-string-literals-in-rust | Last Update : Sat, 20 Jun 20

Question : matching in rust

Answered by : huldar

match number { // Match a single value 1 => println!("One!"), // Match several values 2 | 3 | 5 | 7 | 11 => println!("This is a prime"), // Match an inclusive range 13..=19 => println!("A teen"), // Handle the rest of cases _ => println!("Ain't special"), }

Source : https://doc.rust-lang.org/stable/rust-by-example/flow_control/match.html | Last Update : Tue, 04 Aug 20

Answers related to rust match statement

Code Explorer Popular Question For Rust