#[repr(transparent)]pub struct Optional<T>(pub T);Expand description
Wrap a parser in this to make it always succeed and return an Option.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: TokenTreeExt, X: Parser<T>> Parser<T> for Optional<X>
impl<T: TokenTreeExt, X: Parser<T>> Parser<T> for Optional<X>
Source§type Output<'p, 'b> = Option<<X as Parser<T>>::Output<'p, 'b>>
where
Self: 'p
type Output<'p, 'b> = Option<<X as Parser<T>>::Output<'p, 'b>> where Self: 'p
The output type of this parser.
Source§fn parse<'p, 'b>(
&'p self,
buf: &mut &'b TokenBuf<T>,
) -> Result<Self::Output<'p, 'b>, Error<T::Span>>
fn parse<'p, 'b>( &'p self, buf: &mut &'b TokenBuf<T>, ) -> Result<Self::Output<'p, 'b>, Error<T::Span>>
Parse a value from a
TokenBuf using this parser. Read moreAuto Trait Implementations§
impl<T> Freeze for Optional<T>where
T: Freeze,
impl<T> RefUnwindSafe for Optional<T>where
T: RefUnwindSafe,
impl<T> Send for Optional<T>where
T: Send,
impl<T> Sync for Optional<T>where
T: Sync,
impl<T> Unpin for Optional<T>where
T: Unpin,
impl<T> UnwindSafe for Optional<T>where
T: UnwindSafe,
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