pub struct TupleParser<'doc> { /* private fields */ }Expand description
Helper for parsing tuple types from Eure documents.
Provides both sequential access via next() and random access via get().
Use finish() to verify all elements were consumed.
§Example
ⓘ
let mut tuple = ctx.parse_tuple()?;
let first: String = tuple.next()?;
let second: i32 = tuple.next()?;
tuple.finish()?; // Ensures no extra elementsImplementations§
Source§impl<'doc> TupleParser<'doc>
impl<'doc> TupleParser<'doc>
Sourcepub fn next<T>(&mut self) -> Result<T, T::Error>
pub fn next<T>(&mut self) -> Result<T, T::Error>
Get the next element, advancing the position.
Returns ParseErrorKind::MissingField if no more elements.
Sourcepub fn get<T>(&self, index: usize) -> Result<T, T::Error>
pub fn get<T>(&self, index: usize) -> Result<T, T::Error>
Get the element at a specific index without advancing position.
Returns ParseErrorKind::MissingField if the index is out of bounds.
Sourcepub fn finish(self) -> Result<(), ParseError>
pub fn finish(self) -> Result<(), ParseError>
Verify all elements were consumed.
Returns ParseErrorKind::UnexpectedTupleLength if elements remain.
Sourcepub fn expect_len(&self, expected: usize) -> Result<(), ParseError>
pub fn expect_len(&self, expected: usize) -> Result<(), ParseError>
Verify the tuple has the expected length.
Returns ParseErrorKind::UnexpectedTupleLength if length doesn’t match.
Trait Implementations§
Auto Trait Implementations§
impl<'doc> Freeze for TupleParser<'doc>
impl<'doc> RefUnwindSafe for TupleParser<'doc>
impl<'doc> Send for TupleParser<'doc>
impl<'doc> Sync for TupleParser<'doc>
impl<'doc> Unpin for TupleParser<'doc>
impl<'doc> UnwindSafe for TupleParser<'doc>
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