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 {
116116 return amt;
117117 }
118118
119 pub fn eatUntil(p: *Parser, test_c: u8) !?struct { usize, usize } {
119 pub fn eatUntil(p: *Parser, test_c: u8) !?[2]usize {
120120 const start = p.idx;
121 var len: usize = 0;
122121 while (true) {
123122 try p.peekAmt(1) orelse return null;
124123 const amt = std.mem.indexOfScalar(u8, p.slice(), test_c) orelse {
125124 const left = p.avail();
126 len += left;
127125 p.idx += left;
128126 continue;
129127 };
130 len += amt;
131128 p.idx += amt;
132 return .{ start, len };
129 const end = p.idx;
130 return .{ start, end };
133131 }
134132 }
135133
......@@ -211,7 +209,7 @@ pub fn Mixin(comptime T: type) type {
211209 return pp.parser.trimByte(test_c);
212210 }
213211
214 pub fn eatUntil(pp: *T, test_c: u8) !usize {
212 pub fn eatUntil(pp: *T, test_c: u8) !?[2]usize {
215213 return pp.parser.eatUntil(test_c);
216214 }
217215 };