Last active
September 24, 2023 16:08
-
-
Save mizchi/34efb18865a1894d844964ece42dca33 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 x: Option<Result<(&str, &str), ()>> = Some(Ok(("x", "y"))); | |
// if let | |
if let Some(Ok((a, _))) = x { | |
if a == "x" { | |
println!("a=x"); | |
} | |
} | |
// match | |
match x { | |
Some(Ok((a, _))) => { | |
if a == "x" { | |
println!("a=x"); | |
} | |
} | |
_ => {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment