Enum MathParseErrors

Source
pub enum MathParseErrors {
Show 15 variants UnclosedParenthesis, UnopenedParenthesis, EmptyLine, InvalidNumber(String), MisplacedOperator(char), TrailingOperator, IntConversion(f64), BinaryOpOnFloat(f64, char), ReturnFloatExpectedInt(f64), BadOperatorHint(char, &'static str), UnexpectedZero, UnexpectedNegative, InvalidRPNOperator(char), UnbalancedStack, MathParseInternalBug(String),
}
Expand description

Type used to represent any errors that can happen in the parsing of a math expression.

Variants§

§

UnclosedParenthesis

A parenthesis was opened but never closed.

§

UnopenedParenthesis

A closing parenthesis was used with no matching open parenthesis.

§

EmptyLine

The math expression is empty. Or the right hand side of an operator is empty.

§

InvalidNumber(String)

An expression that should have been a number but can’t be read.

§

MisplacedOperator(char)

An operator is not where it should be. Like a “*” after a “+”, or the left hand side of an operator being empty.

§

TrailingOperator

An operator is the last element of a line of math.

§

IntConversion(f64)

A float could not be converted to an int.

§

BinaryOpOnFloat(f64, char)

A binary operation have been tried on a float.

§

ReturnFloatExpectedInt(f64)

We wanted to return an int but we got a float instead.

§

BadOperatorHint(char, &'static str)

A given operator was invalid, but we can suggest an other instead.

§

UnexpectedZero

There was an unwanted zero.

§

UnexpectedNegative

There was an unwanted negative number.

§

InvalidRPNOperator(char)

An operator is not valid in the context of RPN parsing.

§

UnbalancedStack

The number of elements on the RPN stack is not valid.

§

MathParseInternalBug(String)

This error should never be raised and should be reported to the library’s maintainer.

Trait Implementations§

Source§

impl Debug for MathParseErrors

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MathParseErrors

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

From a MathParseError, makes an error message that could even be shown to the final user.

Source§

impl PartialEq for MathParseErrors

Source§

fn eq(&self, other: &MathParseErrors) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for MathParseErrors

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.