Created
March 10, 2019 17:43
-
-
Save wdevore/721b1d4cb8b094a418016a98cafb3780 to your computer and use it in GitHub Desktop.
Howto extract Option from Cell of type usize
This file contains 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
// How to extract Option from Cell | |
pub struct X { | |
replacement: Cell<Option<usize>>, | |
... | |
} | |
fn get_transition_node(&self) -> usize { | |
if let Some(rep) = &*self.replacement.borrow() { | |
let repl = rep.borrow(); | |
return repl.data().borrow().node.id(); | |
} | |
0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment