pub struct ParseNumberError {
pub message: String,
pub line: usize,
pub column: usize,
}Expand description
Rich parse-error diagnostic carrying the offending message together with the 1-based line and column where the parser stopped.
This is a standalone error type (not a variant of OxiNumError) so that
the existing OxiNumError size envelope is preserved. Convert via
OxiNumError::from(parse_err) (or ?) to fold a positional diagnostic
back into the unified error type — the resulting OxiNumError::Parse
message will include the line and column.
§Examples
use oxinum_core::{OxiNumError, ParseNumberError};
let pe = ParseNumberError::new("unexpected character", 2, 5);
assert!(pe.to_string().contains("line 2"));
assert!(pe.to_string().contains("column 5"));
// Fold into the unified error type.
let e: OxiNumError = pe.into();
assert!(matches!(e, OxiNumError::Parse(_)));
assert!(e.to_string().contains("line 2"));
assert!(e.to_string().contains("col 5"));Fields§
§message: StringHuman-readable description of why the parse failed.
line: usize1-based line where the parser stopped.
column: usize1-based column where the parser stopped.
Implementations§
Trait Implementations§
Source§impl Clone for ParseNumberError
impl Clone for ParseNumberError
Source§fn clone(&self) -> ParseNumberError
fn clone(&self) -> ParseNumberError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ParseNumberError
impl Debug for ParseNumberError
Source§impl Display for ParseNumberError
impl Display for ParseNumberError
Source§impl Error for ParseNumberError
impl Error for ParseNumberError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ParseNumberError> for OxiNumError
impl From<ParseNumberError> for OxiNumError
Source§fn from(e: ParseNumberError) -> Self
fn from(e: ParseNumberError) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ParseNumberError
impl PartialEq for ParseNumberError
Source§fn eq(&self, other: &ParseNumberError) -> bool
fn eq(&self, other: &ParseNumberError) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for ParseNumberError
impl StructuralPartialEq for ParseNumberError
Auto Trait Implementations§
impl Freeze for ParseNumberError
impl RefUnwindSafe for ParseNumberError
impl Send for ParseNumberError
impl Sync for ParseNumberError
impl Unpin for ParseNumberError
impl UnsafeUnpin for ParseNumberError
impl UnwindSafe for ParseNumberError
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