summaryrefslogtreecommitdiff
path: root/src/code_point.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/code_point.zig')
-rw-r--r--src/code_point.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/code_point.zig b/src/code_point.zig
index ba0b434..43b38d2 100644
--- a/src/code_point.zig
+++ b/src/code_point.zig
@@ -15,6 +15,14 @@ pub const CodePoint = struct {
15 pub inline fn bytes(cp: CodePoint, str: []const u8) []const u8 { 15 pub inline fn bytes(cp: CodePoint, str: []const u8) []const u8 {
16 return str[cp.offset..][0..cp.len]; 16 return str[cp.offset..][0..cp.len];
17 } 17 }
18
19 pub fn format(cp: CodePoint, _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
20 try writer.print("CodePoint '{u}' .{{ ", .{cp.code});
21 try writer.print(
22 ".code = 0x{x}, .offset = {d}, .len = {d} }}",
23 .{ cp.code, cp.offset, cp.len },
24 );
25 }
18}; 26};
19 27
20/// This function is deprecated and will be removed in a later release. 28/// This function is deprecated and will be removed in a later release.
@@ -171,7 +179,7 @@ pub const Iterator = struct {
171 179
172 /// Create a backward iterator at this point. It will repeat 180 /// Create a backward iterator at this point. It will repeat
173 /// the last CodePoint seen. 181 /// the last CodePoint seen.
174 pub fn reverseIterator(iter: *Iterator) ReverseIterator { 182 pub fn reverseIterator(iter: *const Iterator) ReverseIterator {
175 if (iter.i == iter.bytes.len) { 183 if (iter.i == iter.bytes.len) {
176 return .init(iter.bytes); 184 return .init(iter.bytes);
177 } 185 }
@@ -283,7 +291,7 @@ pub const ReverseIterator = struct {
283 291
284 /// Create a forward iterator at this point. It will repeat the 292 /// Create a forward iterator at this point. It will repeat the
285 /// last CodePoint seen. 293 /// last CodePoint seen.
286 pub fn forwardIterator(iter: *ReverseIterator) Iterator { 294 pub fn forwardIterator(iter: *const ReverseIterator) Iterator {
287 if (iter.i) |i| { 295 if (iter.i) |i| {
288 var fwd: Iterator = .{ .i = i, .bytes = iter.bytes }; 296 var fwd: Iterator = .{ .i = i, .bytes = iter.bytes };
289 _ = fwd.next(); 297 _ = fwd.next();