Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum SoI {
- S(String),
- I(i32),
- }
- fn main() {
- let s = SoI::S(String::from("one"));
- // why this ?
- match s {
- SoI::S(ref x) if x == "one" => { println!("one") },
- _ => println!("not one"),
- }
- // if it can be done like this?
- match s {
- SoI::S(x) => if x == "one" { println!("one"); },
- _ => println!("not one"),
- }
- }
- // which is more preferable??
Add Comment
Please, Sign In to add comment