diff options
| author | 2026-02-06 13:07:03 -0500 | |
|---|---|---|
| committer | 2026-02-06 13:07:03 -0500 | |
| commit | b823a49b6a57bc1736b33a0816b42aaaf86cf839 (patch) | |
| tree | 533a2ffff737ba2826456fecb01bf3eb187b872a /src/code_point.zig | |
| parent | Slightly better hash reduction for comptime_map (diff) | |
| download | zg-b823a49b6a57bc1736b33a0816b42aaaf86cf839.tar.gz zg-b823a49b6a57bc1736b33a0816b42aaaf86cf839.tar.xz zg-b823a49b6a57bc1736b33a0816b42aaaf86cf839.zip | |
zg module, casing improvements
Diffstat (limited to 'src/code_point.zig')
| -rw-r--r-- | src/code_point.zig | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/code_point.zig b/src/code_point.zig index 7a638af..5f6c61c 100644 --- a/src/code_point.zig +++ b/src/code_point.zig | |||
| @@ -30,13 +30,8 @@ pub const CodePoint = struct { | |||
| 30 | /// This function is deprecated and will be removed in a later release. | 30 | /// This function is deprecated and will be removed in a later release. |
| 31 | /// Use `decodeAtIndex` or `decodeAtCursor`. | 31 | /// Use `decodeAtIndex` or `decodeAtCursor`. |
| 32 | pub fn decode(bytes: []const u8, offset: uoffset) ?CodePoint { | 32 | pub fn decode(bytes: []const u8, offset: uoffset) ?CodePoint { |
| 33 | var off: uoffset = 0; | 33 | _ = .{ bytes, offset }; |
| 34 | var maybe_code = decodeAtCursor(bytes, &off); | 34 | @compileError("decode has been removed, use `decodeAtIndex`."); |
| 35 | if (maybe_code) |*code| { | ||
| 36 | code.offset = offset; | ||
| 37 | return code.*; | ||
| 38 | } | ||
| 39 | return null; | ||
| 40 | } | 35 | } |
| 41 | 36 | ||
| 42 | /// Return the codepoint at `index`, even if `index` is in the middle | 37 | /// Return the codepoint at `index`, even if `index` is in the middle |
| @@ -292,7 +287,7 @@ pub const ReverseIterator = struct { | |||
| 292 | else | 287 | else |
| 293 | iter.i = null; | 288 | iter.i = null; |
| 294 | 289 | ||
| 295 | return decode(iter.bytes[i_prev..], i_prev); | 290 | return decodeAtIndex(iter.bytes, i_prev); |
| 296 | } | 291 | } |
| 297 | 292 | ||
| 298 | pub fn peek(iter: *ReverseIterator) ?CodePoint { | 293 | pub fn peek(iter: *ReverseIterator) ?CodePoint { |
| @@ -319,7 +314,7 @@ inline fn followbyte(b: u8) bool { | |||
| 319 | 314 | ||
| 320 | test "decode" { | 315 | test "decode" { |
| 321 | const bytes = "🌩️"; | 316 | const bytes = "🌩️"; |
| 322 | const res = decode(bytes, 0); | 317 | const res = decodeAtIndex(bytes, 0); |
| 323 | 318 | ||
| 324 | if (res) |cp| { | 319 | if (res) |cp| { |
| 325 | try std.testing.expectEqual(@as(u21, 0x1F329), cp.code); | 320 | try std.testing.expectEqual(@as(u21, 0x1F329), cp.code); |