Guest User

Untitled

a guest
Sep 12th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment