daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn first_some() -> Result<Option<()>, ()> {
  2.     if let Some(x) = foo()? {
  3.         return Ok(Some(x))
  4.     }
  5.     if let Some(x) = bar()? {
  6.         return Ok(Some(x))
  7.     }
  8.     if let Some(x) = baz()? {
  9.         return Ok(Some(x))
  10.     }
  11.     Ok(None)
  12. }
  13.  
  14. fn foo() -> Result<Option<()>, ()> {
  15.     unimplemented!()
  16. }
  17.  
  18. fn bar() -> Result<Option<()>, ()> {
  19.     unimplemented!()
  20. }
  21.  
  22. fn baz() -> Result<Option<()>, ()> {
  23.     unimplemented!()
  24. }
  25.  
  26. fn main() {
  27.     let _ = first_some();
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top