#zig build-obj {
--name test -fno-emit-bin
-Mroot=test.zig
#}

#write test.zig {
const std = @import("std");

export fn entry() void {
    var ohnoes: *usize = undefined;
    _ = sliceAsBytes(ohnoes);
    _ = &ohnoes;
}
fn sliceAsBytes(slice: anytype) isPtrTo(.array)(@TypeOf(slice)) {}

pub const TraitFn = fn (type) bool;

pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {
    const Closure = struct {
        pub fn trait(comptime T: type) bool {
            if (!comptime isSingleItemPtr(T)) return false;
            return id == @typeInfo(std.meta.Child(T));
        }
    };
    return Closure.trait;
}

pub fn isSingleItemPtr(comptime T: type) bool {
    if (comptime is(.pointer)(T)) {
        return @typeInfo(T).pointer.size == .one;
    }
    return false;
}

pub fn is(comptime id: std.builtin.TypeId) TraitFn {
    const Closure = struct {
        pub fn trait(comptime T: type) bool {
            return id == @typeInfo(T);
        }
    };
    return Closure.trait;
}
#}
#update
#check errors {
test.zig:8:48: error: expected type 'type', found 'bool'
test.zig:5:21: note: generic function instantiated here
#}
