authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2021-12-24 11:42:47 -08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-12-24 11:42:47 -08:00
log14c3492c46f9765c3e77436741794d1a3118cbee
tree7c59e61e1c571ed94014fcfaa1356d1c332c5c88
parent9a068122c59ac2785f330c37bf4412aed644ed37
parentcc2e30bd32077ee96a8da65da050e7874d2d7a81
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2 from cursey/allocator-fixes

Fix for Zig std.mem.Allocator changes

1 files changed, 4 insertions(+), 4 deletions(-)

src/lib.zig+4-4
......@@ -14,7 +14,7 @@ const PromptRet = struct {
1414 value: []const u8,
1515};
1616
17fn doprompt(out: anytype, in: anytype, alloc: *std.mem.Allocator, default: ?[]const u8) !PromptRet {
17fn doprompt(out: anytype, in: anytype, alloc: std.mem.Allocator, default: ?[]const u8) !PromptRet {
1818 var n: usize = 1;
1919 var value: []const u8 = undefined;
2020 while (true) : (n += 1) {
......@@ -41,7 +41,7 @@ fn clean(out: anytype, n: usize) !void {
4141 }
4242}
4343
44pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *std.mem.Allocator, comptime options: type, default: ?options) !options {
44pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: std.mem.Allocator, comptime options: type, default: ?options) !options {
4545 comptime std.debug.assert(@typeInfo(options) == .Enum);
4646 const def: ?[]const u8 = if (default) |d| @tagName(d) else null;
4747
......@@ -77,7 +77,7 @@ pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *s
7777 return value;
7878}
7979
80pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *std.mem.Allocator, default: ?[]const u8) ![]const u8 {
80pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc: std.mem.Allocator, default: ?[]const u8) ![]const u8 {
8181 try out.print(comptime ansi.color.Fg(.Green, "? "), .{});
8282 try out.print(comptime ansi.color.Bold(prompt ++ " "), .{});
8383
......@@ -92,7 +92,7 @@ pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc:
9292 return try answer(out, prompt, []const u8, "{s}", p.value);
9393}
9494
95pub fn forConfirm(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *std.mem.Allocator) !bool {
95pub fn forConfirm(out: anytype, in: anytype, comptime prompt: []const u8, alloc: std.mem.Allocator) !bool {
9696 return (try forEnum(out, in, prompt, alloc, enum { y, n }, .y)) == .y;
9797}
9898