authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-26 21:14:09-08:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-12-08 15:59:17+02:00
log6a12fd62c17ea2e054456e71d2a02ac995aa617a
tree7540c212bdd6eff9f35f064844121b4d07f19a52
parent7a46c20a79d9724787d55f3e496155bb5332151a

std: make std.unicode.initComptime() a comptime-known function

resolved a TODO :)

1 files changed, 3 insertions(+), 6 deletions(-)

lib/std/unicode.zig+3-6
......@@ -330,15 +330,12 @@ pub const Utf8View = struct {
330330 return Utf8View{ .bytes = s };
331331 }
332332
333 /// TODO: https://github.com/ziglang/zig/issues/425
334 pub fn initComptime(comptime s: []const u8) Utf8View {
335 if (comptime init(s)) |r| {
336 return r;
337 } else |err| switch (err) {
333 pub inline fn initComptime(comptime s: []const u8) Utf8View {
334 return comptime if (init(s)) |r| r else |err| switch (err) {
338335 error.InvalidUtf8 => {
339336 @compileError("invalid utf8");
340337 },
341 }
338 };
342339 }
343340
344341 pub fn iterator(s: Utf8View) Utf8Iterator {