//! returns: 0 //! Methods called via various pointer indirections. record Counter: Copy { value: i32, } fn (c: &Counter) get() -> i32 { return c.value; } fn (c: &mut Counter) inc() { set c.value = c.value + 1; } @default unsafe fn main() -> i32 { let mut c = Counter { value: 0 }; // Direct call on value. assert c.get() == 0; // Mutable method on value. c.inc(); assert c.get() == 1; // Call via immutable pointer. let p: *unsafe Counter = &c; assert p.get() == 1; // Call via mutable pointer. let mp: *unsafe mut Counter = &mut c; mp.inc(); assert mp.get() == 2; // Original value also updated. assert c.get() == 2; return 0; }