Add ParseError:err_type and ParseError::position.

This commit is contained in:
Stephen Chung
2022-07-29 09:42:30 +08:00
parent 6fab9f5b63
commit ea38185cac
19 changed files with 147 additions and 104 deletions

View File

@@ -299,6 +299,21 @@ impl fmt::Display for ParseError {
}
}
impl ParseError {
/// Get the [type][ParseErrorType] of this parse error.
#[inline(always)]
#[must_use]
pub fn err_type(&self) -> &ParseErrorType {
&self.0
}
/// Get the [position][Position] of this parse error.
#[inline(always)]
#[must_use]
pub fn position(&self) -> Position {
self.1
}
}
impl From<ParseErrorType> for RhaiError {
#[inline(always)]
fn from(err: ParseErrorType) -> Self {