Guest User

Untitled

a guest
Aug 17th, 2019
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[derive(Debug)]
  2. enum ContactMethod {
  3. Email(String),
  4. Phone(String),
  5. }
  6.  
  7. fn inspect(m: ContactMethod) {
  8. print!("Value is {:?}", m);
  9. match m {
  10. // exhaustive pattern matching
  11. ContactMethod::Email(email) => println!("Email is: {}", email),
  12. ContactMethod::Phone(phone) => println!("Phone is: {}", phone),
  13. }
  14. }
  15.  
  16. fn main() {
  17. inspect(ContactMethod::Email("foo@example.com".to_string()));
  18. inspect(ContactMethod::Phone("123456789".to_string()))
  19. }
RAW Paste Data