nandi/rustnimpublic Fork 0
afb2a6e152356d5a78d536ad75f005bb1fc7ed63
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.

Add the differential test runner, and a lowering to measure with it 8ac32af · on afb2a6e152356d5a78d536ad75f005bb1fc7ed63 · nandithebull · 8h ago
010-structs-and-methods.rs · 20 lines · 303 BRust Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
struct Counter {
    value: i32,
    step: i32,
}

impl Counter {
    fn bump(&mut self) {
        self.value += self.step;
    }
    fn get(&self) -> i32 {
        self.value
    }
}

fn main() {
    let mut c = Counter { value: 0, step: 3 };
    c.bump();
    c.bump();
    println!("{}", c.get());
}