Created
April 8, 2019 20:24
-
-
Save rust-play/e4d4e7fc2120a26ea97af8a295fd6e62 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains 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 Control { | |
pub id: i32, | |
} | |
struct UI<'a> { | |
pub control: &'a Control, | |
} | |
impl Control { | |
fn new(n: i32) -> Control { | |
Control { id: n } | |
} | |
} | |
impl<'a> UI<'a> { | |
fn new(c: &'a Control) -> UI { | |
UI { control: c } | |
} | |
} | |
fn main() { | |
let c = Control::new(99); | |
let ui = UI::new(&c); | |
println!("{}", ui.control.id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment