-
-
Save Dustinturner44/6d0e8d189e704c53ddc199a1b262b65a to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Inner { | |
| a: A, | |
| } | |
| impl Inner { | |
| fn fun(&mut self) { | |
| self.a.something(); | |
| } | |
| fn fun2(&mut self, outer: &Arc<Outer>) { | |
| self.a.something2(outer.b); | |
| } | |
| } | |
| struct Outer { | |
| b: B, | |
| inner: Mutex<Inner>, | |
| } | |
| impl Outer { | |
| fn mainfun(self: Arc<Self>) { | |
| let mut inner = self.inner.lock(); | |
| // do something with held locks | |
| inner.fun2(&self); | |
| // do something more | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment