Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::marker::PhantomData;
- struct Inner<'a> {
- _phantom: PhantomData<&'a ()>,
- }
- impl<'a> Inner<'a> {
- fn do_a_thing(&mut self) {}
- }
- struct Outer<'a> {
- x: &'a mut Inner<'a>,
- }
- impl<'a> Outer<'a> {
- fn act_on_inner(&mut self) {
- self.x.do_a_thing();
- }
- }
- fn f<'a>(x: &'a mut Inner<'a>) {
- let mut outer = Outer { x: x };
- outer.act_on_inner();
- }
- fn main() {
- let mut x = Inner {
- _phantom: PhantomData,
- };
- f(&mut x);
- f(&mut x);
- }
Add Comment
Please, Sign In to add comment