authorgravatar for cursey@live.comcursey <cursey@live.com> 2021-12-17 20:45:15 -08:00
committergravatar for cursey@live.comcursey <cursey@live.com> 2021-12-17 20:45:15 -08:00
logcc2e30bd32077ee96a8da65da050e7874d2d7a81
tree7c59e61e1c571ed94014fcfaa1356d1c332c5c88
parent9a068122c59ac2785f330c37bf4412aed644ed37
signaturelock-open Commit is signed but in an unrecognized format.

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 {...@@ -14,7 +14,7 @@ const PromptRet = struct {
14 value: []const u8,14 value: []const u8,
15};15};
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 {
18 var n: usize = 1;18 var n: usize = 1;
19 var value: []const u8 = undefined;19 var value: []const u8 = undefined;
20 while (true) : (n += 1) {20 while (true) : (n += 1) {
...@@ -41,7 +41,7 @@ fn clean(out: anytype, n: usize) !void {...@@ -41,7 +41,7 @@ fn clean(out: anytype, n: usize) !void {
41 }41 }
42}42}
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 {
45 comptime std.debug.assert(@typeInfo(options) == .Enum);45 comptime std.debug.assert(@typeInfo(options) == .Enum);
46 const def: ?[]const u8 = if (default) |d| @tagName(d) else null;46 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...@@ -77,7 +77,7 @@ pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *s
77 return value;77 return value;
78}78}
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 {
81 try out.print(comptime ansi.color.Fg(.Green, "? "), .{});81 try out.print(comptime ansi.color.Fg(.Green, "? "), .{});
82 try out.print(comptime ansi.color.Bold(prompt ++ " "), .{});82 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:...@@ -92,7 +92,7 @@ pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc:
92 return try answer(out, prompt, []const u8, "{s}", p.value);92 return try answer(out, prompt, []const u8, "{s}", p.value);
93}93}
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 {
96 return (try forEnum(out, in, prompt, alloc, enum { y, n }, .y)) == .y;96 return (try forEnum(out, in, prompt, alloc, enum { y, n }, .y)) == .y;
97}97}
9898