Created
March 29, 2017 08:51
-
-
Save mitsuhiko/474725b6872853bf14a07d0f788258a9 to your computer and use it in GitHub Desktop.
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
fn get_nsmap_mut(&mut self) -> &mut NamespaceMap { | |
if self.nsmap.is_none() { | |
self.nsmap = Some(Rc::new(NamespaceMap::new())); | |
} | |
{ | |
let nsmap_copy = { | |
let nsmap = self.nsmap.as_mut().unwrap(); | |
if Rc::strong_count(nsmap) == 1 { | |
return Rc::get_mut(nsmap).unwrap() | |
} | |
(**nsmap).clone() | |
}; | |
self.nsmap = Some(Rc::new(nsmap_copy)); | |
} | |
Rc::get_mut(self.nsmap.as_mut().unwrap()).unwrap() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment