Skip to content

Instantly share code, notes, and snippets.

Created April 19, 2016 20:54
Show Gist options
  • Save anonymous/1076c83401fd1f315daeabc00b82c196 to your computer and use it in GitHub Desktop.
Save anonymous/1076c83401fd1f315daeabc00b82c196 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#[derive(Debug)]
struct Parent {
count: u8,
}
#[derive(Debug)]
struct Child<'a> {
parent: &'a Parent,
}
#[derive(Debug)]
struct Combined<'a> {
parent: Box<Parent>,
child: Child<'a>,
}
fn main() {
let p = Box::new(Parent { count: 42 });
let c = Child { parent: &*p };
let c = Combined { parent: p, child: c };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment