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
When parser successfully parse the stream
Fields
token: Token
token produced by the parser.
stream: Stream
the stream used by the parser, should have less item than before.
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>
Source§impl<Token, Stream, Context> Try for Parsed<Token, Stream, Context>
impl<Token, Stream, Context> Try for Parsed<Token, Stream, Context>
Source§type Output = Success<Token, Stream>
type Output = Success<Token, Stream>
try_trait_v2
)?
when not short-circuiting.Source§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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§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