Skip to content

Instantly share code, notes, and snippets.

@aneurysmjs
Last active September 11, 2024 14:53
Show Gist options
  • Save aneurysmjs/a05095f5fe3721eb542bccdd1c53e4b1 to your computer and use it in GitHub Desktop.
Save aneurysmjs/a05095f5fe3721eb542bccdd1c53e4b1 to your computer and use it in GitHub Desktop.
Rust cheatsheet
// represents the `possible` absence of a value
enum Option<T> {
Some(T),
None,
}
let email: Option<String> = Some(email_str);
let email: Option<String> = None;
// represents an operation that could have failed
enum Result<O, E> {
Ok(O),
Err(E),
}
let success: Result<i64, String> = Ok(42);
let failure: Result<i64, String> = Err(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment