Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct Thing {
- list: Vec<i32>,
- }
- impl Thing {
- fn do_more(&mut self, x: &mut i32) {
- *x *= 2;
- }
- fn do_mut(&mut self, v: i32) {
- self.list.push(v);
- let x = self.list.last_mut().unwrap();
- self.do_more(x);
- }
- }
- fn main() {
- let mut t = Thing { list: Vec::new() };
- t.do_mut(1);
- println!("Done!");
- }
Add Comment
Please, Sign In to add comment