mirror of
https://github.com/ziglang/zig.git
synced 2024-11-28 08:02:32 +00:00
19 lines
263 B
Zig
19 lines
263 B
Zig
|
pub fn main() void {
|
||
|
var x: u8 = undefined;
|
||
|
const maybe_x = byPtr(&x);
|
||
|
assert(maybe_x != null);
|
||
|
maybe_x.?.* = 255;
|
||
|
assert(x == 255);
|
||
|
}
|
||
|
|
||
|
fn byPtr(x: *u8) ?*u8 {
|
||
|
return x;
|
||
|
}
|
||
|
|
||
|
fn assert(ok: bool) void {
|
||
|
if (!ok) unreachable;
|
||
|
}
|
||
|
|
||
|
// run
|
||
|
//
|