Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn first_some() -> Result<Option<()>, ()> {
- if let Some(x) = foo()? {
- return Ok(Some(x))
- }
- if let Some(x) = bar()? {
- return Ok(Some(x))
- }
- if let Some(x) = baz()? {
- return Ok(Some(x))
- }
- Ok(None)
- }
- fn foo() -> Result<Option<()>, ()> {
- unimplemented!()
- }
- fn bar() -> Result<Option<()>, ()> {
- unimplemented!()
- }
- fn baz() -> Result<Option<()>, ()> {
- unimplemented!()
- }
- fn main() {
- let _ = first_some();
- }
Add Comment
Please, Sign In to add comment