pub struct Acceptor<'a, 'b, T, V> { /* private fields */ }Expand description
A type that wraps a Scanner and holds a successfully accepted value.
When a value is successfully accepted, the Acceptor stores the value in its
data field and returns itself. If a value is not accepted, the Acceptor
rewinds the scanner to the previous position and returns itself.
§Type Parameters
T- The type of the data to scan.V- The type of the value to accept.'a- The lifetime of the data to scan.'b- The lifetime of the acceptor.
Implementations§
Source§impl<'a, T, V> Acceptor<'a, '_, T, V>
impl<'a, T, V> Acceptor<'a, '_, T, V>
Sourcepub fn try_or<U: Visitor<'a, T>, F>(self, transformer: F) -> ParseResult<Self>where
F: Fn(U) -> V,
pub fn try_or<U: Visitor<'a, T>, F>(self, transformer: F) -> ParseResult<Self>where
F: Fn(U) -> V,
Attempt to accept a U using the given transformer, and rewind the scanner
and return the current acceptor if it fails.
§Arguments
transformer- A function that takes aUand returns aParseResult<V>.
§Returns
If the U is successfully accepted and the transformer returns Ok, returns
the current acceptor with the resulting value in data. If the U is not
successfully accepted, returns the current acceptor with the current position
of the scanner rewound to the position at which the U was attempted, and
data is left None.
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'b, T, V> Freeze for Acceptor<'a, 'b, T, V>where
V: Freeze,
impl<'a, 'b, T, V> RefUnwindSafe for Acceptor<'a, 'b, T, V>where
V: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, 'b, T, V> Send for Acceptor<'a, 'b, T, V>
impl<'a, 'b, T, V> Sync for Acceptor<'a, 'b, T, V>
impl<'a, 'b, T, V> Unpin for Acceptor<'a, 'b, T, V>where
V: Unpin,
impl<'a, 'b, T, V> !UnwindSafe for Acceptor<'a, 'b, T, V>
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