Skip to content

Instantly share code, notes, and snippets.

Created October 13, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/c67bd767fc70fc6f6403 to your computer and use it in GitHub Desktop.
Save anonymous/c67bd767fc70fc6f6403 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
struct Foo<'a> {
x: &'a u32,
y: u32,
}
#[allow(dead_code)]
fn bar<'a>(f: &'a mut Foo<'a>, _z: &'a u32) {
f.x = &f.y;
}
fn main() {
let z = &32u32;
let mut f = Foo{x: z, y: 33u32};
{
let f2 = &mut f;
bar(f2, z);
}
// println!("{}", f.x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment