#[repr(u8)]pub enum ParseErrorReason {
UnexpectedToken,
InputIsEmpty,
UnbalancedBrackets,
TwoInnersWithoutOperator,
TwoOperatorsWithoutInner,
MustNotStartWith,
UnitsNotEqual(UnitsNotEqual),
NotConvertibleFromComplexF64(NotConvertibleFromComplexF64),
CouldNotParse,
}Expand description
The varying reasons parsing a string to a
DynQuantity can fail.
This struct is part of ParseError, which contains the information where
the parsing failed.
Variants§
UnexpectedToken
String contained an unexpected token.
InputIsEmpty
Input string was empty.
UnbalancedBrackets
Brackets in the string are not balanced:
- “((5)”: Closing bracket is missing
- “(5))”: Opening bracket is missing
TwoInnersWithoutOperator
Two numbers without any combining operator are in the string:
- “5 32”: Invalid because it is unclear how the numbers should
combined in the resulting
DynQuantity. - “5 * 32”: Valid
TwoOperatorsWithoutInner
Two operators without a number inbetween are in the string:
- “3 / * 2”: Invalid
- “3 / 1 * 2”: Valid
MustNotStartWith
The string must not start with certain characters, for example:
- Operators such as *, /, ^
- Closing brackets
UnitsNotEqual(UnitsNotEqual)
An addition / subtraction of two invalid quantities was defined in the string, e.g. “3 A + 2 V”.
NotConvertibleFromComplexF64(NotConvertibleFromComplexF64)
See docstring of NotConvertibleFromComplexF64.
CouldNotParse
Generic fallback error for all other parsing failures
Trait Implementations§
Source§impl Clone for ParseErrorReason
impl Clone for ParseErrorReason
Source§fn clone(&self) -> ParseErrorReason
fn clone(&self) -> ParseErrorReason
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 Debug for ParseErrorReason
impl Debug for ParseErrorReason
Source§impl Default for ParseErrorReason
impl Default for ParseErrorReason
Source§fn default() -> ParseErrorReason
fn default() -> ParseErrorReason
Returns the “default value” for a type. Read more
Source§impl Display for ParseErrorReason
impl Display for ParseErrorReason
Source§impl Error for ParseErrorReason
impl Error for ParseErrorReason
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<UnitsNotEqual> for ParseErrorReason
impl From<UnitsNotEqual> for ParseErrorReason
Source§fn from(value: UnitsNotEqual) -> ParseErrorReason
fn from(value: UnitsNotEqual) -> ParseErrorReason
Converts to this type from the input type.
Source§impl PartialEq for ParseErrorReason
impl PartialEq for ParseErrorReason
impl StructuralPartialEq for ParseErrorReason
Auto Trait Implementations§
impl Freeze for ParseErrorReason
impl RefUnwindSafe for ParseErrorReason
impl Send for ParseErrorReason
impl Sync for ParseErrorReason
impl Unpin for ParseErrorReason
impl UnsafeUnpin for ParseErrorReason
impl UnwindSafe for ParseErrorReason
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