nandi/rustnimpublic Fork 0
0e6c394efb2da64065352ff67a15f6cba4e8899a
Commits
Clone
git clone https://git.rickub.com/nandi/rustnim.git
git clone ssh://git@rickub.com/nandi/rustnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

010-structs-and-methods.rs · 20 lines · 303 BRust Blame HistoryRaw
Add the differential test runner, and a lowering to measure with it 8ac32af nandithebull 20h ago1struct Counter {
2 value: i32,
3 step: i32,
4}
5
6impl Counter {
7 fn bump(&mut self) {
8 self.value += self.step;
9 }
10 fn get(&self) -> i32 {
11 self.value
12 }
13}
14
15fn main() {
16 let mut c = Counter { value: 0, step: 3 };
17 c.bump();
18 c.bump();
19 println!("{}", c.get());
20}