#[std]
struct Counter {
let count: num;
fn new() -> Counter { return 0 as Counter }
fn increment(self: &Counter) {
self->count += 1;
}
fn decrement(self: &Counter) {
self->count -= 1;
}
}
fn inc(c: Counter) {
// c is a copy, it does not affect the
// Counter given to the function
c.increment();
c.increment();
c.increment();
putstr("this should print 3 => "); putnumln(c->count);
}
fn main() {
let c = Counter::new();
putstr("this should print 0 => "); putnumln(c->count);
inc(c);
putstr("this should print 0 => "); putnumln(c->count);
}