SHARE
TWEET

Untitled

a guest Oct 17th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top