diff --git a/src/isIndexable.zig b/src/isIndexable.zig index 8afe9cf018685b7765c0b8d09874c8b3feb63ea6..9e0cd48da221ee366575e0ccdb08ea801094a04c 100644 --- a/src/isIndexable.zig +++ b/src/isIndexable.zig @@ -1,6 +1,7 @@ const std = @import("std"); const string = []const u8; const extras = @import("./lib.zig"); +const isTuple = extras.isTuple; pub fn isIndexable(comptime T: type) bool { if (comptime is(.pointer)(T)) { @@ -19,9 +20,6 @@ fn is(comptime id: std.builtin.TypeId) fn (type) bool { }; return Closure.trait; } -fn isTuple(comptime T: type) bool { - return is(.@"struct")(T) and @typeInfo(T).@"struct".is_tuple; -} test { const array = [_]u8{0} ** 10; diff --git a/src/isTuple.zig b/src/isTuple.zig new file mode 100644 index 0000000000000000000000000000000000000000..a606bf52287c388f88b04891cf58952c03a30f3c --- /dev/null +++ b/src/isTuple.zig @@ -0,0 +1,15 @@ +const std = @import("std"); +const string = []const u8; +const extras = @import("./lib.zig"); + +pub fn isTuple(comptime T: type) bool { + return is(.@"struct")(T) and @typeInfo(T).@"struct".is_tuple; +} +fn is(comptime id: std.builtin.TypeId) fn (type) bool { + const Closure = struct { + pub fn trait(comptime T: type) bool { + return id == @typeInfo(T); + } + }; + return Closure.trait; +} diff --git a/src/lib.zig b/src/lib.zig index cdb650202ccba376dacbcb97a17f2e2cd07884c7..1985b7b2834105bf3994ab8faac1532933e56525 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -89,6 +89,7 @@ pub const compareFnSlice = @import("./compareFnSlice.zig").compareFnSlice; pub const sumLen = @import("./sumLen.zig").sumLen; pub const splitScalarN = @import("./splitScalarN.zig").splitScalarN; pub const indexOfAggregate = @import("./indexOfAggregate.zig").indexOfAggregate; +pub const isTuple = @import("./isTuple.zig").isTuple; test { _ = @import("reduceNumber.zig"); @@ -167,4 +168,5 @@ test { _ = @import("sumLen.zig"); _ = @import("splitScalarN.zig"); _ = @import("indexOfAggregate.zig"); + _ = @import("isTuple.zig"); }