Guest User

Untitled

a guest
Dec 14th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum AnotherThing<'a> {
  3. Tux(&'a str),
  4. Baz,
  5. }
  6.  
  7. #[derive(Debug)]
  8. enum Foo<'a> {
  9. Bar(String),
  10. Baz(u8),
  11. OhGod(AnotherThing<'a>),
  12. }
  13.  
  14. fn main() {
  15. let x = Some(Foo::OhGod(AnotherThing::Tux("hi!")));
  16.  
  17. match x {
  18. Some(Foo::OhGod(AnotherThing::Tux("hi!"))) => {
  19. println!("Matched on hi!");
  20. }
  21.  
  22. Some(Foo::OhGod(AnotherThing::Tux(_))) => {
  23. println!("This is super contrived!");
  24. }
  25. whatever => {
  26. println!("got whatever this is: {:?}", whatever);
  27. }
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment