pub(crate) enum StringContext {
Label(String),
Description(String),
ExpectedChar(char),
ExpectedString(&'static str),
ExpectedText(String),
}Expand description
A single piece of parser context that is attached to a ParseStack error.
In contrast to winnow’s StrContext, which only holds &'static str, this types allows
messages as Strings.
This allows for setting error messages during runtime, which is a requirement for translated messages and generally provides more flexibility.
Variants§
Label(String)
A description of what is currently being parsed.
Description(String)
A free-form description of what went wrong.
ExpectedChar(char)
An expected char literal.
ExpectedString(&'static str)
An expected string literal.
Use this for known, static syntax/keywords.
ExpectedText(String)
An free-form string that explains what is expected.
Use this for known, static syntax/keywords.
Implementations§
Source§impl StringContext
impl StringContext
Sourcepub(crate) fn label(&self) -> Option<&str>
pub(crate) fn label(&self) -> Option<&str>
Returns the label text in case this context is a StringContext::Label.
Sourcepub(crate) fn expected(&self) -> Option<String>
pub(crate) fn expected(&self) -> Option<String>
Returns the expected literal if Self is of a literal variant.
Sourcefn render_char(c: char) -> String
fn render_char(c: char) -> String
Renders an expected char.
This is copied over from winnow’s StrContextValue Display impl.
Trait Implementations§
Source§impl Clone for StringContext
impl Clone for StringContext
Source§fn clone(&self) -> StringContext
fn clone(&self) -> StringContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more