Skip to content

Instantly share code, notes, and snippets.

@metaleap
Last active January 18, 2020 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaleap/151dc7fbcf73f7073800af189ebdfc85 to your computer and use it in GitHub Desktop.
Save metaleap/151dc7fbcf73f7073800af189ebdfc85 to your computer and use it in GitHub Desktop.
pub inline fn isStr(comptime it: type) bool {
return switch (@typeInfo(it)) {
std.builtin.TypeId.Array => |ta| u8 == ta.child,
std.builtin.TypeId.Pointer => |tp| u8 == tp.child or switch (@typeInfo(tp.child)) {
std.builtin.TypeId.Array => |tpa| u8 == tpa.child,
else => false,
},
else => false,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment