Created
May 27, 2021 06:16
-
-
Save brookback/d606038a461f5628008e379c5677334f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let lol: Option<&str> = Some("lol"); | |
if lol.is_none() { | |
// do some error handling | |
return; | |
} | |
// I'd love if `lol` was asserted to be Some("lol") | |
// below this if clause. | |
assert_eq!(lol, Some("lol")); | |
// …buuut it's not, so I must (is this safe now?!) unwrap() | |
// it to work with its value. | |
let lel = lol.unwrap(); | |
assert_eq!(lel, "lol"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment