Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Compilable Rust Example
struct SomeStruct{
data: uint
}
impl SomeStruct{
fn setData (&mut self, value: uint) {
self.data = value
}
fn getData (&self) -> uint {
self.data
}
fn incrementData (&mut self) {
self.setData(self.getData() + 1);
}
}
fn main () {
let mut foo = SomeStruct{data: 0};
println!("{}", foo.getData());
foo.incrementData();
foo.incrementData();
println!("{}", foo.getData());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.