From f62fbbaed8cdc779c7f647b34f07c388305c6bcd Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 19 Aug 2015 14:26:19 +0200 Subject: [PATCH] Cleanup ActorRegistry::create_shareable. --- components/devtools/actor.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index 8cc9a2231ed..cf2dab9050d 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -110,16 +110,18 @@ impl ActorRegistry { } /// Creating shareable registry - pub fn create_shareable(self) -> Arc>{ - if self.shareable.is_some() { - return self.shareable.unwrap(); + pub fn create_shareable(self) -> Arc> { + if let Some(shareable) = self.shareable { + return shareable; } let shareable = Arc::new(Mutex::new(self)); - let mut lock = shareable.lock(); - let registry = lock.as_mut().unwrap(); - registry.shareable = Some(shareable.clone()); - shareable.clone() + { + let mut lock = shareable.lock(); + let registry = lock.as_mut().unwrap(); + registry.shareable = Some(shareable.clone()); + } + shareable } /// Get shareable registry through threads