Upgrade to winnow 0.7 (#7198)

This commit is contained in:
Jonathan Tran
2025-05-27 14:24:22 -04:00
committed by GitHub
parent 91b6db0ba5
commit cc2769e907
5 changed files with 183 additions and 179 deletions

View File

@ -251,6 +251,11 @@ impl<'a> Stream for TokenSlice<'a> {
Some(token)
}
/// Split off the next token from the input
fn peek_token(&self) -> Option<Self::Token> {
Some(self.first()?.clone())
}
fn offset_for<P>(&self, predicate: P) -> Option<usize>
where
P: Fn(Self::Token) -> bool,
@ -278,6 +283,17 @@ impl<'a> Stream for TokenSlice<'a> {
next
}
/// Split off a slice of tokens from the input
fn peek_slice(&self, offset: usize) -> Self::Slice {
assert!(self.start + offset <= self.end);
TokenSlice {
stream: self.stream,
start: self.start,
end: self.start + offset,
}
}
fn checkpoint(&self) -> Self::Checkpoint {
Checkpoint(self.start, self.end)
}