diff options
author | 2022-07-09 20:15:27 -0500 | |
---|---|---|
committer | 2022-07-09 18:25:25 -0700 | |
commit | f5d896542ae5a9e0b62c73d386727392d32489e0 (patch) | |
tree | c3b18523b5863cfc00f0334625eb71c996ea4651 /src/string_immutable.zig | |
parent | 961d0a159a774074971773bca1aec68e2b539604 (diff) | |
download | bun-f5d896542ae5a9e0b62c73d386727392d32489e0.tar.gz bun-f5d896542ae5a9e0b62c73d386727392d32489e0.tar.zst bun-f5d896542ae5a9e0b62c73d386727392d32489e0.zip |
fix: update build files to latest Zig version
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r-- | src/string_immutable.zig | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 8f347b047..479342025 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -16,11 +16,19 @@ pub inline fn contains(self: string, str: string) bool { } pub fn toUTF16Literal(comptime str: []const u8) []const u16 { - const Static = struct { - pub const literal = std.unicode.utf8ToUtf16LeStringLiteral(str); - }; + comptime { + comptime var output: [str.len]u16 = undefined; + + for (str) |c, i| { + output[i] = c; + } - return Static.literal; + const Static = struct { + pub const literal: []const u16 = output[0..]; + }; + + return Static.literal; + } } const OptionalUsize = std.meta.Int(.unsigned, @bitSizeOf(usize) - 1); @@ -2863,7 +2871,7 @@ test "decodeHexToBytes" { var good: [4096]u8 = undefined; var ours_buf: [4096]u8 = undefined; var match = try std.fmt.hexToBytes(good[0..1024], hex); - var ours = decodeHexToBytes(&ours_buf, hex); + var ours = decodeHexToBytes(&ours_buf, u8, hex); try std.testing.expectEqualSlices(u8, match, ours_buf[0..ours]); try std.testing.expectEqualSlices(u8, &buffer, ours_buf[0..ours]); } @@ -3016,7 +3024,7 @@ pub fn firstNonASCII16CheckMin(comptime Slice: type, slice: Slice, comptime chec return null; } -/// Fast path for printing template literal strings +/// Fast path for printing template literal strings pub fn @"nextUTF16NonASCIIOr$`\\"( comptime Slice: type, slice: Slice, |