mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 15:42:49 +00:00
19 lines
261 B
Zig
19 lines
261 B
Zig
pub fn main() void {
|
|
var x: i8 = undefined;
|
|
const maybe_x = byPtr(&x);
|
|
assert(maybe_x != null);
|
|
maybe_x.?.* = -1;
|
|
assert(x == -1);
|
|
}
|
|
|
|
fn byPtr(x: *i8) ?*i8 {
|
|
return x;
|
|
}
|
|
|
|
fn assert(ok: bool) void {
|
|
if (!ok) unreachable;
|
|
}
|
|
|
|
// run
|
|
//
|