Last active
August 29, 2015 14:02
-
-
Save Gankra/481ca253d89cfea60dbe to your computer and use it in GitHub Desktop.
Simple Compilable Rust Example
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
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