Question : rust match with enum
Answered by : himanshu-jangid
enum IpAddr { V4, V6,
}
fn main() { let ip = IpAddr::V6; match ip { IpAddr::V4 => println!("Yes Ip Is V4"), _ => println!("No Ip is not V4"), }
}
Source : | Last Update : Sun, 04 Sep 22
Question : rust match enum
Answered by : duco
//suppose this was passed by the user and you stored in a variable let choice = Choice::One; match choice { Choice::One => println!("Option 1"), Choice::Two => println!("Option 2"), Choice::Three => println!("Option 3"), }
Source : | Last Update : Tue, 16 Nov 21