-
-
Save steveklabnik/b258d64bd81f734fc07909fbc491d12a 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, | |
} | |
impl<'a> Thing<'a> { | |
fn new(lib: &'a Lib) -> Thing { | |
Thing { | |
lib_obj: lib, | |
} | |
} | |
fn lib_widget(&self) -> &LibWdiget { | |
self.get_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