Values & References7 / 18
Up next

Mutate through a pointer

const std = @import("std");

// increment the pointee in place (like Rust's &mut)
fn bump(n: *u32) void {
    n.* += 1;
}

pub fn main() void {
    var count: u32 = 0;
    bump(&count);
    bump(&count);
    std.debug.print("{d}\n", .{count});
}
What you're solving

*T is Zig's mutable-reference