From e3f0ba4984f932cd3a9a99504d540b4cd8393364 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 13 Sep 2018 11:24:57 -0400 Subject: alternate fix using the rest() function --- src/util.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index 060d7f8fb5..192d74e766 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -78,6 +78,16 @@ Optional> SplitIterator_next(SplitIterator *self) { return Optional>::some(self->buffer.slice(start, end)); } +// Ported from std/mem.zig +Slice SplitIterator_rest(SplitIterator *self) { + // move to beginning of token + size_t index = self->index; + while (index < self->buffer.len && SplitIterator_isSplitByte(self, self->buffer.ptr[index])) { + index += 1; + } + return self->buffer.sliceFrom(index); +} + // Ported from std/mem.zig SplitIterator memSplit(Slice buffer, Slice split_bytes) { return SplitIterator{0, buffer, split_bytes}; -- cgit v1.2.3