Skip to content

Conversation

@nektro
Copy link
Contributor

@nektro nektro commented May 12, 2023

std.mem.TokenIterator already has a method by this name

@squeek502
Copy link
Member

squeek502 commented Jun 3, 2023

This will need to be rebased now that #15579 has been merged

The updated implementation to handle the other delimiter types could be something like:

        pub fn peek(self: *Self) ?[]const T {
            const start = self.index orelse return null;
            const end = if (switch (delimiter_type) {
                .sequence => indexOfPos(T, self.buffer, start, self.delimiter),
                .any => indexOfAnyPos(T, self.buffer, start, self.delimiter),
                .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),
            }) |delim_start| delim_start else self.buffer.len;
            return self.buffer[start..end];
        }

@andrewrk andrewrk merged commit cd0594e into ziglang:master Jul 10, 2023
@nektro nektro deleted the patch-5 branch July 10, 2023 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants