Skip to content

std: add mem.SplitIterator.peek() - #15670

Merged
andrewrk merged 3 commits into
ziglang:masterfrom
nektro:patch-5
Jul 10, 2023
Merged

std: add mem.SplitIterator.peek()#15670
andrewrk merged 3 commits into
ziglang:masterfrom
nektro:patch-5

Conversation

@nektro

Copy link
Copy Markdown
Contributor

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

@squeek502

squeek502 commented Jun 3, 2023

Copy link
Copy Markdown
Member

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:

pubfnpeek(self: *Self) ?[]constT {
conststart=self.indexorelsereturnnull;
constend=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_startelseself.buffer.len;
returnself.buffer[start..end];
}

@andrewrk
andrewrk merged commit cd0594e into ziglang:masterJul 10, 2023
@nektro
nektro deleted the patch-5 branch July 10, 2023 18:40
Sign up for freeto 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

@nektro@squeek502@andrewrk