authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-23 01:22:31 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-23 01:22:31 -07:00
loged98b6d8080e99a84940a25011f3f60334648f7f
tree2b97fd00eb62a2deb0dd9f1313bdf4250e5a7ccf
parent03849b83b473f8fbc9c3aac34aa3da5c2e6b9ea3

fix eatUntil return type


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

intrusive_parser.zig+4-6
...@@ -116,20 +116,18 @@ pub const Parser = struct {...@@ -116,20 +116,18 @@ pub const Parser = struct {
116 return amt;116 return amt;
117 }117 }
118118
119 pub fn eatUntil(p: *Parser, test_c: u8) !?struct { usize, usize } {119 pub fn eatUntil(p: *Parser, test_c: u8) !?[2]usize {
120 const start = p.idx;120 const start = p.idx;
121 var len: usize = 0;
122 while (true) {121 while (true) {
123 try p.peekAmt(1) orelse return null;122 try p.peekAmt(1) orelse return null;
124 const amt = std.mem.indexOfScalar(u8, p.slice(), test_c) orelse {123 const amt = std.mem.indexOfScalar(u8, p.slice(), test_c) orelse {
125 const left = p.avail();124 const left = p.avail();
126 len += left;
127 p.idx += left;125 p.idx += left;
128 continue;126 continue;
129 };127 };
130 len += amt;
131 p.idx += amt;128 p.idx += amt;
132 return .{ start, len };129 const end = p.idx;
130 return .{ start, end };
133 }131 }
134 }132 }
135133
...@@ -211,7 +209,7 @@ pub fn Mixin(comptime T: type) type {...@@ -211,7 +209,7 @@ pub fn Mixin(comptime T: type) type {
211 return pp.parser.trimByte(test_c);209 return pp.parser.trimByte(test_c);
212 }210 }
213211
214 pub fn eatUntil(pp: *T, test_c: u8) !usize {212 pub fn eatUntil(pp: *T, test_c: u8) !?[2]usize {
215 return pp.parser.eatUntil(test_c);213 return pp.parser.eatUntil(test_c);
216 }214 }
217 };215 };