Created
August 9, 2016 15:11
-
-
Save anonymous/5bf670bd47556d608144b461165185e5 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Lib { | |
// whatever... but it implements Drop | |
} | |
impl Lib { | |
fn get_widget() -> &LibWidget { | |
// unimportant (I think), but LibWidget implements Drop | |
} | |
} | |
struct Thing<'a> { | |
lib_obj: &'a Lib, | |
lib_widget: &'a LibWidget, | |
} | |
impl<'a> Thing<'a> { | |
fn new(lib: &'a Lib) -> Thing { | |
let widget = lib.get_widget(); | |
Thing { | |
lib_obj: lib, | |
lib_widget: widget, | |
} | |
} | |
} | |
fn main() { | |
let lib = Lib::new(); | |
let thing = Thing::new(&lib); | |
// do stuff with thing... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment