Skip to content

Instantly share code, notes, and snippets.

@winksaville
Last active September 17, 2018 23:24
Show Gist options
  • Save winksaville/61239d52598c334c2671f9183a359f82 to your computer and use it in GitHub Desktop.
Save winksaville/61239d52598c334c2671f9183a359f82 to your computer and use it in GitHub Desktop.
Test ?*u0
const std = @import("std");
const assert = std.debug.assert;
const warn = std.debug.warn;
const builtin = @import("builtin");
const TypeId = builtin.TypeId;
test "u0" {
var zero: u0 = 0;
var pZeroOptional: ?*u0 = &zero;
assert(pZeroOptional != null); // this is true
assert(pZeroOptional == &zero);// And this is true
if (pZeroOptional != null) {
assert(pZeroOptional.?.* == 0);
} else {
unreachable;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment