Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created June 21, 2019 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/661886ccc40a576f47d8d6cbfffe436e to your computer and use it in GitHub Desktop.
Save rust-play/661886ccc40a576f47d8d6cbfffe436e to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![allow(unused)]
struct A {
b: usize,
c: Vec<isize>,
}
impl A {
fn e(&mut self) {
let A {
b,
c: ref mut d,
} = self;
d.push(3);
self.c.push(4)
}
}
fn main() {
let mut a = &mut A {
b: 1,
c: vec![2],
};
a.e();
println!("{:?}", a.c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment