Skip to content

Instantly share code, notes, and snippets.

@prepor
Created February 9, 2018 15:59
Show Gist options
  • Save prepor/a09412cc824675648569c729ba9a378d to your computer and use it in GitHub Desktop.
Save prepor/a09412cc824675648569c729ba9a378d to your computer and use it in GitHub Desktop.
enum Bar {
One(String),
Two(String)
}
struct Foo {
bars: Vec<Bar>
}
impl Foo {
fn x(&mut self) {
let case = match self.bars[0] {
Bar::One(ref c) => 1,
Bar::Two(_) => 2
};
match case {
1 => self.y(),
2 => self.y(),
_ => panic!("oh!")
}
}
fn y(&mut self) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment