mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
std: make std.unicode.initComptime() a comptime-known function
resolved a TODO :)
This commit is contained in:
parent
7a46c20a79
commit
6a12fd62c1
@ -330,15 +330,12 @@ pub const Utf8View = struct {
|
||||
return Utf8View{ .bytes = s };
|
||||
}
|
||||
|
||||
/// TODO: https://github.com/ziglang/zig/issues/425
|
||||
pub fn initComptime(comptime s: []const u8) Utf8View {
|
||||
if (comptime init(s)) |r| {
|
||||
return r;
|
||||
} else |err| switch (err) {
|
||||
pub inline fn initComptime(comptime s: []const u8) Utf8View {
|
||||
return comptime if (init(s)) |r| r else |err| switch (err) {
|
||||
error.InvalidUtf8 => {
|
||||
@compileError("invalid utf8");
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn iterator(s: Utf8View) Utf8Iterator {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user