Skip to content

Instantly share code, notes, and snippets.

@aaripurna
Created July 23, 2021 15:38
Show Gist options
  • Save aaripurna/b291ca3926c37cc7b1cca8b56ca91fb9 to your computer and use it in GitHub Desktop.
Save aaripurna/b291ca3926c37cc7b1cca8b56ca91fb9 to your computer and use it in GitHub Desktop.
Null handling in rust
// Sometimes will retun None
fn some_operation() -> Option<String> {
// Some operation that may return None
}
fn write_text() {
match some_iperation() {
Some(text) => println!("{}", text),
None => println!("There is nothing")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment