Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created February 15, 2016 20:43
Show Gist options
  • Save adamhjk/1974b883c843fb1d5836 to your computer and use it in GitHub Desktop.
Save adamhjk/1974b883c843fb1d5836 to your computer and use it in GitHub Desktop.
Sample of exhaustive pattern matching
pub fn wait_for_leader(&self) -> bool {
self.wait_for_it(Duration::seconds(5), || {
let election = self.election();
match election.find_path(&["mine", "status"]) {
Some(status) => match status.as_string() {
Some("Finished") => true,
Some(_) => false,
None => false,
},
None => false,
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment