Skip to content

Instantly share code, notes, and snippets.

@wdevore
Created March 10, 2019 17:43
Show Gist options
  • Save wdevore/721b1d4cb8b094a418016a98cafb3780 to your computer and use it in GitHub Desktop.
Save wdevore/721b1d4cb8b094a418016a98cafb3780 to your computer and use it in GitHub Desktop.
Howto extract Option from Cell of type usize
// 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