Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created December 13, 2018 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rust-play/61f10904c11f1283bdebc6c3b20f86ce to your computer and use it in GitHub Desktop.
Save rust-play/61f10904c11f1283bdebc6c3b20f86ce to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn print(n: Option<i32>) {
// conditionally destructure
if let Some(inner) = n {
println!("Val: {}", inner);
}
}
fn main() {
print(None);
print(Some(0));
print(Some(5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment