Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct A { /* ... */ }
- struct B { /* ... */ }
- struct C {
- a: A,
- b: B,
- }
- impl A {
- fn close(self) -> Result<(), A> { /* ... */ }
- }
- impl B {
- fn close(self) -> Result<(), B> { /* ... */ }
- }
- impl C {
- fn close(self) -> Result<(), C> {
- let C { a, b } = self;
- match a.close() {
- Ok(()) => {}
- Err(a) => return Err(C { a, b }),
- }
- match b.close() {
- Ok(()) => Ok(())
- Err(b) => {
- // panic? store an `Option<A>`? different error?
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement