pub struct InputPart<'a, P: Input> { /* private fields */ }
Expand description
A helper struct for checking if the next token matches your expectations and consuming the token thereupon. Instances of this type can be created with the following methods:
Implementations§
Source§impl<'a, P: Input> InputPart<'a, P>
impl<'a, P: Input> InputPart<'a, P>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the token currently looked at is empty, i.e. has a length of 0
Sourcepub fn take(self, len: usize) -> InputPart<'a, P>
pub fn take(self, len: usize) -> InputPart<'a, P>
If the token is longer than len
bytes, use only the first len
bytes
of this token. The rest of the string is considered part of the next
token.
Sourcepub fn take_char(self) -> Option<InputPart<'a, P>>
pub fn take_char(self) -> Option<InputPart<'a, P>>
Ignore everything but the first char of the token. The rest of the string is considered part of the next token.
This returns None
if the token is empty.
Sourcepub fn take_until(self, c: char) -> InputPart<'a, P>
pub fn take_until(self, c: char) -> InputPart<'a, P>
If the token contains c
, use only the part of the token before the
first occurrence of c
. The rest of the string is considered part
of the next token.
Trait Implementations§
Auto Trait Implementations§
impl<'a, P> Freeze for InputPart<'a, P>
impl<'a, P> RefUnwindSafe for InputPart<'a, P>where
P: RefUnwindSafe,
impl<'a, P> Send for InputPart<'a, P>where
P: Send,
impl<'a, P> Sync for InputPart<'a, P>where
P: Sync,
impl<'a, P> Unpin for InputPart<'a, P>
impl<'a, P> !UnwindSafe for InputPart<'a, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more