pub trait Label {
type LabelError;
// Required method
fn push(&mut self, found: char) -> Result<Option<char>, Self::LabelError>;
// Provided method
fn complete(&mut self) -> Result<Option<char>, Self::LabelError> { ... }
}Expand description
A trait for extracting the label from a boundary
Required Associated Types§
Sourcetype LabelError
type LabelError
The type of any errors which might occur while accumulating the label
Required Methods§
Sourcefn push(&mut self, found: char) -> Result<Option<char>, Self::LabelError>
fn push(&mut self, found: char) -> Result<Option<char>, Self::LabelError>
Adds a character to the label. If it returns an error, the parsing process will terminate.
A return value of Ok(Some(found)) means the label was expected to end.
A return value of Ok(Some(expected)) means a Mismatch error occured.
Provided Methods§
Sourcefn complete(&mut self) -> Result<Option<char>, Self::LabelError>
fn complete(&mut self) -> Result<Option<char>, Self::LabelError>
Signals that the label is complete because a double '-' was reached.
Defaults to Ok(None).
A return value of Ok(Some(expected)) is interpreted as a Mismatch error.
A return value of Ok(Some('-')) is invalid and reserved for future use.