Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::cell::Cell;
- //#[derive(Clone)]
- struct Foo
- {
- data: Cell<u32>
- }
- #[derive(Clone)]
- struct Bar<'a>
- {
- inner: &'a Foo
- }
- fn main() {
- let a = Foo { data: Cell::new(7) };
- let b = Bar { inner: &a };
- {
- let c = b.clone();
- c.inner.data.set(1);
- }
- println!("{}", a.data.get());
- }
Add Comment
Please, Sign In to add comment