SHARE
TWEET

Untitled

a guest Jul 17th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct A { /* ... */ }
  2. struct B { /* ... */ }
  3. struct C {
  4.     a: A,
  5.     b: B,
  6. }
  7.  
  8. impl A {
  9.     fn close(self) -> Result<(), A> { /* ... */ }
  10. }
  11. impl B {
  12.     fn close(self) -> Result<(), B> { /* ... */ }
  13. }
  14.  
  15. impl C {
  16.     fn close(self) -> Result<(), C> {
  17.         let C { a, b } = self;
  18.         match a.close() {
  19.             Ok(()) => {}
  20.             Err(a) => return Err(C { a, b }),
  21.         }
  22.         match b.close() {
  23.             Ok(()) => Ok(())
  24.             Err(b) => {
  25.                 // panic? store an `Option<A>`? different error?
  26.             }
  27.         }
  28.     }
  29. }
RAW Paste Data
Top