Skip to content

Commit

Permalink
WIP: zig-clap v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Hejsil committed Nov 18, 2024
1 parent cfa86f6 commit 91962aa
Show file tree
Hide file tree
Showing 3 changed files with 1,181 additions and 2 deletions.
8 changes: 6 additions & 2 deletions clap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2132,14 +2132,18 @@ test "usage" {

test {
_ = args;
_ = ccw;
_ = parsers;
_ = streaming;
_ = ccw;
_ = v1;
_ = v2;
}

pub const args = @import("clap/args.zig");
pub const ccw = @import("clap/codepoint_counting_writer.zig");
pub const parsers = @import("clap/parsers.zig");
pub const streaming = @import("clap/streaming.zig");
pub const ccw = @import("clap/codepoint_counting_writer.zig");
pub const v1 = @This();
pub const v2 = @import("clap/v2.zig");

const std = @import("std");
23 changes: 23 additions & 0 deletions clap/types.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pub fn isArrayListUnmanaged(comptime T: type) bool {
if (@typeInfo(T) != .@"struct" or !@hasDecl(T, "Slice"))
return false;

const ptr_info = switch (@typeInfo(T.Slice)) {
.pointer => |info| info,
else => return false,
};

return T == std.ArrayListAlignedUnmanaged(ptr_info.child, null) or
T == std.ArrayListAlignedUnmanaged(ptr_info.child, ptr_info.alignment);
}

test isArrayListUnmanaged {
try std.testing.expect(!isArrayListUnmanaged(u8));
try std.testing.expect(!isArrayListUnmanaged([]const u8));
try std.testing.expect(!isArrayListUnmanaged(struct {
pub const Slice = []const u8;
}));
try std.testing.expect(isArrayListUnmanaged(std.ArrayListUnmanaged(u8)));
}

const std = @import("std");
Loading

0 comments on commit 91962aa

Please sign in to comment.