Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. struct S;
  2.  
  3. impl S {
  4. fn process(&mut self, v: usize) { }
  5.  
  6. fn test1(&mut self) -> Result<usize, ()> {
  7. unimplemented!()
  8. }
  9.  
  10. fn test2(&mut self) -> Result<usize, ()> {
  11. unimplemented!()
  12. }
  13.  
  14. fn test3(&mut self) -> Result<usize, ()> {
  15. unimplemented!()
  16. }
  17.  
  18. // ...
  19.  
  20. fn multi(&mut self) -> Result<usize, ()> {
  21. let tests = [
  22. Self::test1,
  23. Self::test2,
  24. Self::test3,
  25. // ...
  26. ];
  27.  
  28. for &test in &tests {
  29. if let Ok(v) = test(self) {
  30. self.process(v);
  31. return Ok(v);
  32. }
  33. }
  34.  
  35. Err(())
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement