Guest User

Untitled

a guest
Jun 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. use std::cell::RefCell;
  2. use std::rc::Rc;
  3.  
  4. struct Foo {
  5. bar: Rc<RefCell<Option<String>>>,
  6. }
  7.  
  8. impl Foo {
  9. fn baz(&self) {
  10. self.bar.borrow().as_ref().map(|f| println!("{:?}", f)); // This should print the Option<T>
  11. }
  12. }
  13.  
  14.  
  15. fn main() {
  16. let foo = Foo { bar: Rc::new(RefCell::new(None)) };
  17. }
Add Comment
Please, Sign In to add comment