Created
June 21, 2019 00:48
-
-
Save rust-play/661886ccc40a576f47d8d6cbfffe436e 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
#![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