Skip to content

Instantly share code, notes, and snippets.

@pnkfelix
Last active December 20, 2015 20:49
Show Gist options
  • Save pnkfelix/6192665 to your computer and use it in GitHub Desktop.
Save pnkfelix/6192665 to your computer and use it in GitHub Desktop.
struct S { x: int }
impl S {
fn f(self) {
let mut ms = self;
println(fmt!("self pre: %? ms pre: %?", self, ms));
ms.x = 4;
println(fmt!("self post: %? ms post: %?", self, ms));
}
}
fn main() {
let s = S { x: 3 };
s.f();
}
% rustc /tmp/boz.rs && /tmp/boz
warning: no debug symbols in executable (-arch x86_64)
self pre: {x: 3} ms pre: {x: 3}
self post: {x: 3} ms post: {x: 4}
%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment