pub struct YggdrasilError<R> {
pub variant: ErrorKind<R>,
pub location: InputLocation,
pub line_col: LineColLocation,
/* private fields */
}Expand description
Parse-related error type.
Fields§
§variant: ErrorKind<R>Variant of the error
location: InputLocationLocation within the input string
line_col: LineColLocationLine/column within the input string
Implementations§
Source§impl<R> YggdrasilError<R>where
R: YggdrasilRule,
impl<R> YggdrasilError<R>where
R: YggdrasilRule,
Sourcepub fn new_from_offset(
variant: ErrorKind<R>,
pos: Position<'_>,
) -> YggdrasilError<R>
pub fn new_from_offset( variant: ErrorKind<R>, pos: Position<'_>, ) -> YggdrasilError<R>
Creates Error from ErrorVariant and Position.
§Examples
let error = YggdrasilError::new_from_offset(
ErrorKind::ParsingError {
positives: vec![Rule::open_paren],
negatives: vec![Rule::closed_paren],
},
pos,
);
println!("{}", error);Sourcepub fn new_from_span(
variant: ErrorKind<R>,
span: TextSpan<'_>,
) -> YggdrasilError<R>
pub fn new_from_span( variant: ErrorKind<R>, span: TextSpan<'_>, ) -> YggdrasilError<R>
Creates Error from ErrorVariant and Span.
§Examples
let error = YggdrasilError::new_from_span(
ErrorKind::ParsingError {
positives: vec![Rule::open_paren],
negatives: vec![Rule::closed_paren],
},
span,
);
println!("{}", error);Sourcepub fn invalid_node(expect: R, span: TextSpan<'_>) -> YggdrasilError<R>
pub fn invalid_node(expect: R, span: TextSpan<'_>) -> YggdrasilError<R>
unable to create node
Sourcepub fn missing_tag(
expect: Cow<'static, str>,
span: TextSpan<'_>,
) -> YggdrasilError<R>
pub fn missing_tag( expect: Cow<'static, str>, span: TextSpan<'_>, ) -> YggdrasilError<R>
unable to create node
Sourcepub fn missing_rule(expect: R, span: TextSpan<'_>) -> YggdrasilError<R>
pub fn missing_rule(expect: R, span: TextSpan<'_>) -> YggdrasilError<R>
missing rule
Sourcepub fn with_path(self, path: &str) -> YggdrasilError<R>
pub fn with_path(self, path: &str) -> YggdrasilError<R>
Returns Error variant with path which is shown when formatted with Display.
§Examples
YggdrasilError::new_from_offset(
ErrorKind::ParsingError {
positives: vec![Rule::open_paren],
negatives: vec![Rule::closed_paren],
},
pos,
)
.with_path("file.rs");Sourcepub fn path(&self) -> Option<&str>
pub fn path(&self) -> Option<&str>
Returns the path set using YggdrasilError::with_path().
§Examples
let error = error.with_path("file.rs");
assert_eq!(Some("file.rs"), error.path());Sourcepub fn renamed_rules<F>(self, f: F) -> YggdrasilError<R>
pub fn renamed_rules<F>(self, f: F) -> YggdrasilError<R>
Renames all Rules if this is a ParsingError. It does nothing when called on a
CustomError.
Useful in order to rename verbose rules or have detailed per-Rule formatting.
§Examples
YggdrasilError::new_from_offset(
ErrorKind::ParsingError {
positives: vec![Rule::open_paren],
negatives: vec![Rule::closed_paren],
},
pos,
)
.renamed_rules(|rule| match *rule {
Rule::open_paren => "(".to_owned(),
Rule::closed_paren => "closed paren".to_owned(),
});Trait Implementations§
Source§impl<R> Clone for YggdrasilError<R>where
R: Clone,
impl<R> Clone for YggdrasilError<R>where
R: Clone,
Source§fn clone(&self) -> YggdrasilError<R>
fn clone(&self) -> YggdrasilError<R>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<R> Debug for YggdrasilError<R>where
R: Debug,
impl<R> Debug for YggdrasilError<R>where
R: Debug,
Source§impl<R> Display for YggdrasilError<R>where
R: YggdrasilRule,
impl<R> Display for YggdrasilError<R>where
R: YggdrasilRule,
Source§impl<R> Hash for YggdrasilError<R>where
R: Hash,
impl<R> Hash for YggdrasilError<R>where
R: Hash,
Source§impl<R> PartialEq for YggdrasilError<R>where
R: PartialEq,
impl<R> PartialEq for YggdrasilError<R>where
R: PartialEq,
impl<R> Eq for YggdrasilError<R>where
R: Eq,
impl<R> StructuralPartialEq for YggdrasilError<R>
Auto Trait Implementations§
impl<R> Freeze for YggdrasilError<R>where
R: Freeze,
impl<R> RefUnwindSafe for YggdrasilError<R>where
R: RefUnwindSafe,
impl<R> Send for YggdrasilError<R>where
R: Send,
impl<R> Sync for YggdrasilError<R>where
R: Sync,
impl<R> Unpin for YggdrasilError<R>where
R: Unpin,
impl<R> UnwindSafe for YggdrasilError<R>where
R: 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