Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- enum AnotherThing<'a> {
- Tux(&'a str),
- Baz,
- }
- #[derive(Debug)]
- enum Foo<'a> {
- Bar(String),
- Baz(u8),
- OhGod(AnotherThing<'a>),
- }
- fn main() {
- let x = Some(Foo::OhGod(AnotherThing::Tux("hi!")));
- match x {
- Some(Foo::OhGod(AnotherThing::Tux("hi!"))) => {
- println!("Matched on hi!");
- }
- Some(Foo::OhGod(AnotherThing::Tux(_))) => {
- println!("This is super contrived!");
- }
- whatever => {
- println!("got whatever this is: {:?}", whatever);
- }
- }
- }
Add Comment
Please, Sign In to add comment