[−][src]Struct lenient_semver_parser::Error
Possible errors that happen during parsing and the location of the token where the error occurred.
Example
use semver::Version; let error = lenient_semver_parser::parse::<Version>("1+").unwrap_err(); assert_eq!(error.to_string(), "Could not parse the build identifier: No input"); let error = lenient_semver_parser::parse::<Version>("1!").unwrap_err(); assert_eq!(error.to_string(), "Unexpected `!`");
Implementations
impl<'input> Error<'input>
[src]
pub fn owned(&self) -> OwnedError
[src]
Creates a new OwnedError
out of this Error
.
This is specialized version of Clone
which returns a different type.
pub fn input(&self) -> &'input str
[src]
Returns the original input line.
Examples
let error = lenient_semver_parser::parse::<semver::Version>("1+").unwrap_err(); assert_eq!(error.input(), "1+");
pub fn error_span(&self) -> Range<usize>
[src]
Returns range into the input string that points to the erroneous input.
Examples
let error = lenient_semver_parser::parse::<semver::Version>("1!").unwrap_err(); assert_eq!(error.error_span(), 1..2);
pub fn error_kind(&self) -> ErrorKind
[src]
Returns the kind of error.
Examples
assert_eq!( lenient_semver_parser::parse::<semver::Version>("").unwrap_err().error_kind(), lenient_semver_parser::ErrorKind::MissingMajorNumber ); assert_eq!( lenient_semver_parser::parse::<semver::Version>("1.").unwrap_err().error_kind(), lenient_semver_parser::ErrorKind::MissingMinorNumber ); assert_eq!( lenient_semver_parser::parse::<semver::Version>("1.2.").unwrap_err().error_kind(), lenient_semver_parser::ErrorKind::MissingPatchNumber ); assert_eq!( lenient_semver_parser::parse::<semver::Version>("1-").unwrap_err().error_kind(), lenient_semver_parser::ErrorKind::MissingPreRelease ); assert_eq!( lenient_semver_parser::parse::<semver::Version>("1+").unwrap_err().error_kind(), lenient_semver_parser::ErrorKind::MissingBuild ); assert_eq!( lenient_semver_parser::parse::<semver::Version>("1!").unwrap_err().error_kind(), lenient_semver_parser::ErrorKind::UnexpectedInput );
pub fn erroneous_input(&self) -> &'input str
[src]
Returns a slice from the original input line that triggered the error.
Examples
let error = lenient_semver_parser::parse::<semver::Version>("1!").unwrap_err(); assert_eq!(error.erroneous_input(), "!");
pub fn error_line(&self) -> String
[src]
Returns a text representation of the error.
Examples
let error = lenient_semver_parser::parse::<semver::Version>("1.").unwrap_err(); assert_eq!(error.error_line(), String::from("Could not parse the minor identifier: No input"));
This is equivalent to the Display
implementation, which can be further customized with format specifiers.
let error = lenient_semver_parser::parse::<semver::Version>("1?").unwrap_err(); assert_eq!(format!("{:!^42}", error), String::from("!!!!!!!!!!!!!!Unexpected `?`!!!!!!!!!!!!!!"));
pub fn indicate_erroneous_input(&self) -> String
[src]
Returns a caret line indication the erroneous input if it was written under the original input line.
Examples
let error = lenient_semver_parser::parse::<semver::Version>("foo").unwrap_err(); assert_eq!(error.indicate_erroneous_input(), "^"); let error = lenient_semver_parser::parse::<semver::Version>("1.2.3 bar").unwrap_err(); assert_eq!(error.indicate_erroneous_input(), "~~~~~~^");
Trait Implementations
impl<'input> Debug for Error<'input>
[src]
impl<'_> Display for Error<'_>
[src]
impl<'input> Eq for Error<'input>
[src]
impl<'_> Error for Error<'_>
[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<'_> Ord for Error<'_>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'input> PartialEq<Error<'input>> for Error<'input>
[src]
impl<'_> PartialOrd<Error<'_>> for Error<'_>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'input> StructuralEq for Error<'input>
[src]
impl<'input> StructuralPartialEq for Error<'input>
[src]
Auto Trait Implementations
impl<'input> RefUnwindSafe for Error<'input>
impl<'input> Send for Error<'input>
impl<'input> Sync for Error<'input>
impl<'input> Unpin for Error<'input>
impl<'input> UnwindSafe for Error<'input>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,