pub enum Parsed<Token, Stream, Context> {
Success {
token: Token,
stream: Stream,
},
Failure(Context),
Error(Context),
}
Expand description
Parsed represent the result of a parse()
.
Variants§
Success
Fields
token: Token
token produced by the parser.
stream: Stream
the stream used by the parser, should have less item than before.
When parser successfully parse the stream
Failure(Context)
When parser fail to parse the stream. This is not fatal and is a normal behavior for a parser.
Error(Context)
When parser encouter an error, this should be fatal. Could be a programming error or something wrong will the stream.
Implementations§
source§impl<Token, Stream, Context> Parsed<Token, Stream, Context>
impl<Token, Stream, Context> Parsed<Token, Stream, Context>
sourcepub const fn new_success(token: Token, stream: Stream) -> Self
pub const fn new_success(token: Token, stream: Stream) -> Self
Shortcut for Parsed::Success { token, stream }
sourcepub const fn new_failure(content: Context) -> Self
pub const fn new_failure(content: Context) -> Self
Shortcut for Parsed::Failure(context_handle)
sourcepub const fn as_ref(&self) -> Parsed<&Token, &Stream, &Context>
pub const fn as_ref(&self) -> Parsed<&Token, &Stream, &Context>
Borrow Parsed
to make temporary Parsed of reference
sourcepub fn map_success<MappedToken, Map>(
self,
map: Map
) -> Parsed<MappedToken, Stream, Context>
pub fn map_success<MappedToken, Map>( self, map: Map ) -> Parsed<MappedToken, Stream, Context>
Allow to quickly access success to map it.
sourcepub fn map_token<MappedToken, Map>(
self,
map: Map
) -> Parsed<MappedToken, Stream, Context>where
Map: FnOnce(Token) -> MappedToken,
pub fn map_token<MappedToken, Map>(
self,
map: Map
) -> Parsed<MappedToken, Stream, Context>where
Map: FnOnce(Token) -> MappedToken,
Allow to quickly access token to map it.
sourcepub fn map_stream<Map>(self, map: Map) -> Parsed<Token, Stream, Context>where
Map: FnOnce(Stream) -> Stream,
pub fn map_stream<Map>(self, map: Map) -> Parsed<Token, Stream, Context>where
Map: FnOnce(Stream) -> Stream,
Allow to quickly access stream to map it.
sourcepub fn map_context<MappedAtom, Map>(
self,
map: Map
) -> Parsed<Token, Stream, MappedAtom>where
Map: FnOnce(Context) -> MappedAtom,
pub fn map_context<MappedAtom, Map>(
self,
map: Map
) -> Parsed<Token, Stream, MappedAtom>where
Map: FnOnce(Context) -> MappedAtom,
Allow to quickly access context to map it.
sourcepub fn add_context<C, Map>(self, map: Map) -> Parsed<Token, Stream, Context>where
Map: FnOnce() -> C,
Context: Contexting<C>,
pub fn add_context<C, Map>(self, map: Map) -> Parsed<Token, Stream, Context>where
Map: FnOnce() -> C,
Context: Contexting<C>,
Shortcut to add a Atom to the Context
sourcepub fn unwrap(self) -> Success<Token, Stream>where
Context: Debug,
pub fn unwrap(self) -> Success<Token, Stream>where
Context: Debug,
Return Success if Parsed is Success otherwise panic. Use only for testing purpose.
sourcepub fn unwrap_context(self) -> Context
pub fn unwrap_context(self) -> Context
Return Context if Parsed is Failure or Error otherwise panic. Use only for testing purpose.
sourcepub const fn is_success(&self) -> bool
pub const fn is_success(&self) -> bool
Return true if Parsed is Success.
Trait Implementations§
source§impl<'de, Token, Stream, Context> Deserialize<'de> for Parsed<Token, Stream, Context>
impl<'de, Token, Stream, Context> Deserialize<'de> for Parsed<Token, Stream, Context>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<Token, Stream, Context> FromResidual<ParsedAux<Infallible, Context>> for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> FromResidual<ParsedAux<Infallible, Context>> for Parsed<Token, Stream, Context>
source§fn from_residual(residual: ParsedAux<Infallible, Context>) -> Self
fn from_residual(residual: ParsedAux<Infallible, Context>) -> Self
try_trait_v2
)Residual
type. Read moresource§impl<Token, Stream, Context> FromResidual<Result<Infallible, Context>> for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> FromResidual<Result<Infallible, Context>> for Parsed<Token, Stream, Context>
source§fn from_residual(residual: Result<Infallible, Context>) -> Self
fn from_residual(residual: Result<Infallible, Context>) -> Self
try_trait_v2
)Residual
type. Read moresource§impl<Token, Stream, Context> FromResidual for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> FromResidual for Parsed<Token, Stream, Context>
source§fn from_residual(residual: Parsed<Infallible, Infallible, Context>) -> Self
fn from_residual(residual: Parsed<Infallible, Infallible, Context>) -> Self
try_trait_v2
)Residual
type. Read moresource§impl<Token: Ord, Stream: Ord, Context: Ord> Ord for Parsed<Token, Stream, Context>
impl<Token: Ord, Stream: Ord, Context: Ord> Ord for Parsed<Token, Stream, Context>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<Token: PartialEq, Stream: PartialEq, Context: PartialEq> PartialEq for Parsed<Token, Stream, Context>
impl<Token: PartialEq, Stream: PartialEq, Context: PartialEq> PartialEq for Parsed<Token, Stream, Context>
source§impl<Token: PartialOrd, Stream: PartialOrd, Context: PartialOrd> PartialOrd for Parsed<Token, Stream, Context>
impl<Token: PartialOrd, Stream: PartialOrd, Context: PartialOrd> PartialOrd for Parsed<Token, Stream, Context>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Token, Stream, Context> Try for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> Try for Parsed<Token, Stream, Context>
§type Output = Success<Token, Stream>
type Output = Success<Token, Stream>
try_trait_v2
)?
when not short-circuiting.§type Residual = Parsed<Infallible, Infallible, Context>
type Residual = Parsed<Infallible, Infallible, Context>
try_trait_v2
)FromResidual::from_residual
as part of ?
when short-circuiting. Read moresource§fn from_output(output: Self::Output) -> Self
fn from_output(output: Self::Output) -> Self
try_trait_v2
)Output
type. Read moresource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
try_trait_v2
)?
to decide whether the operator should produce a value
(because this returned ControlFlow::Continue
)
or propagate a value back to the caller
(because this returned ControlFlow::Break
). Read moreimpl<Token: Eq, Stream: Eq, Context: Eq> Eq for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> StructuralPartialEq for Parsed<Token, Stream, Context>
Auto Trait Implementations§
impl<Token, Stream, Context> Freeze for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> RefUnwindSafe for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> Send for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> Sync for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> Unpin for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> UnwindSafe for Parsed<Token, Stream, Context>
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
source§fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
source§fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
source§fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
source§fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
source§fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
source§fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
source§fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
source§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
source§fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
source§fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
source§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
source§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
source§fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
source§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
source§fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
source§fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
source§fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
source§fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
source§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
source§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
source§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
source§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
source§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
source§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
source§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
source§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
source§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
source§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
source§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
source§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
source§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
source§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
source§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
source§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
source§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
source§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
source§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
source§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
source§fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
source§fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
source§fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
source§fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
source§fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
source§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
source§fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
source§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moresource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more