EvalexprError

Enum EvalexprError 

Source
#[non_exhaustive]
pub enum EvalexprError<NumericTypes: EvalexprNumericTypes = DefaultNumericTypes> {
Show 39 variants WrongOperatorArgumentAmount { expected: usize, actual: usize, }, WrongFunctionArgumentAmount { expected: RangeInclusive<usize>, actual: usize, }, ExpectedString { actual: Value<NumericTypes>, }, ExpectedInt { actual: Value<NumericTypes>, }, ExpectedFloat { actual: Value<NumericTypes>, }, ExpectedNumber { actual: Value<NumericTypes>, }, ExpectedNumberOrString { actual: Value<NumericTypes>, }, ExpectedBoolean { actual: Value<NumericTypes>, }, ExpectedTuple { actual: Value<NumericTypes>, }, ExpectedFixedLengthTuple { expected_length: usize, actual: Value<NumericTypes>, }, ExpectedRangedLengthTuple { expected_length: RangeInclusive<usize>, actual: Value<NumericTypes>, }, ExpectedEmpty { actual: Value<NumericTypes>, }, AppendedToLeafNode, PrecedenceViolation, VariableIdentifierNotFound(String), FunctionIdentifierNotFound(String), TypeError { expected: Vec<ValueType>, actual: Value<NumericTypes>, }, WrongTypeCombination { operator: Operator<NumericTypes>, actual: Vec<ValueType>, }, UnmatchedLBrace, UnmatchedRBrace, UnmatchedDoubleQuote, MissingOperatorOutsideOfBrace, UnmatchedPartialToken { first: PartialToken<NumericTypes>, second: Option<PartialToken<NumericTypes>>, }, AdditionError { augend: Value<NumericTypes>, addend: Value<NumericTypes>, }, SubtractionError { minuend: Value<NumericTypes>, subtrahend: Value<NumericTypes>, }, NegationError { argument: Value<NumericTypes>, }, MultiplicationError { multiplicand: Value<NumericTypes>, multiplier: Value<NumericTypes>, }, DivisionError { dividend: Value<NumericTypes>, divisor: Value<NumericTypes>, }, ModulationError { dividend: Value<NumericTypes>, divisor: Value<NumericTypes>, }, InvalidRegex { regex: String, message: String, }, ContextNotMutable, IllegalEscapeSequence(String), BuiltinFunctionsCannotBeEnabled, BuiltinFunctionsCannotBeDisabled, OutOfBoundsAccess, IntFromUsize { usize_int: usize, }, IntIntoUsize { int: NumericTypes::Int, }, RandNotEnabled, CustomMessage(String),
}
Expand description

Errors used in this crate.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

WrongOperatorArgumentAmount

An operator was called with a wrong amount of arguments.

Fields

§expected: usize

The expected amount of arguments.

§actual: usize

The actual amount of arguments.

§

WrongFunctionArgumentAmount

A function was called with a wrong amount of arguments.

Fields

§expected: RangeInclusive<usize>

The expected amount of arguments.

§actual: usize

The actual amount of arguments.

§

ExpectedString

A string value was expected.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedInt

An integer value was expected.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedFloat

A float value was expected.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedNumber

A numeric value was expected. Numeric values are the variants Value::Int and Value::Float.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedNumberOrString

A numeric or string value was expected. Numeric values are the variants Value::Int and Value::Float.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedBoolean

A boolean value was expected.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedTuple

A tuple value was expected.

Fields

§actual: Value<NumericTypes>

The actual value.

§

ExpectedFixedLengthTuple

A tuple value of a certain length was expected.

Fields

§expected_length: usize

The expected length.

§actual: Value<NumericTypes>

The actual value.

§

ExpectedRangedLengthTuple

A tuple value of a certain length range was expected.

Fields

§expected_length: RangeInclusive<usize>

The expected length range.

§actual: Value<NumericTypes>

The actual value.

§

ExpectedEmpty

An empty value was expected.

Fields

§actual: Value<NumericTypes>

The actual value.

§

AppendedToLeafNode

Tried to append a child to a leaf node. Leaf nodes cannot have children.

§

PrecedenceViolation

Tried to append a child to a node such that the precedence of the child is not higher. This error should never occur. If it does, please file a bug report.

§

VariableIdentifierNotFound(String)

A VariableIdentifier operation did not find its value in the context.

§

FunctionIdentifierNotFound(String)

A FunctionIdentifier operation did not find its value in the context.

§

TypeError

A value has the wrong type. Only use this if there is no other error that describes the expected and provided types in more detail.

Fields

§expected: Vec<ValueType>

The expected types.

§actual: Value<NumericTypes>

The actual value.

§

WrongTypeCombination

An operator is used with a wrong combination of types.

Fields

§operator: Operator<NumericTypes>

The operator that whose evaluation caused the error.

§actual: Vec<ValueType>

The types that were used in the operator causing it to fail.

§

UnmatchedLBrace

An opening brace without a matching closing brace was found.

§

UnmatchedRBrace

A closing brace without a matching opening brace was found.

§

UnmatchedDoubleQuote

A double quote without a matching second double quote was found.

§

MissingOperatorOutsideOfBrace

Left of an opening brace or right of a closing brace is a token that does not expect the brace next to it. For example, writing 4(5) would yield this error, as the 4 does not have any operands.

§

UnmatchedPartialToken

A PartialToken is unmatched, such that it cannot be combined into a full Token. This happens if for example a single = is found, surrounded by whitespace. It is not a token, but it is part of the string representation of some tokens.

Fields

§first: PartialToken<NumericTypes>

The unmatched partial token.

§second: Option<PartialToken<NumericTypes>>

The token that follows the unmatched partial token and that cannot be matched to the partial token, or None, if first is the last partial token in the stream.

§

AdditionError

An addition operation performed by Rust failed.

Fields

§augend: Value<NumericTypes>

The first argument of the addition.

§addend: Value<NumericTypes>

The second argument of the addition.

§

SubtractionError

A subtraction operation performed by Rust failed.

Fields

§minuend: Value<NumericTypes>

The first argument of the subtraction.

§subtrahend: Value<NumericTypes>

The second argument of the subtraction.

§

NegationError

A negation operation performed by Rust failed.

Fields

§argument: Value<NumericTypes>

The argument of the negation.

§

MultiplicationError

A multiplication operation performed by Rust failed.

Fields

§multiplicand: Value<NumericTypes>

The first argument of the multiplication.

§multiplier: Value<NumericTypes>

The second argument of the multiplication.

§

DivisionError

A division operation performed by Rust failed.

Fields

§dividend: Value<NumericTypes>

The first argument of the division.

§divisor: Value<NumericTypes>

The second argument of the division.

§

ModulationError

A modulation operation performed by Rust failed.

Fields

§dividend: Value<NumericTypes>

The first argument of the modulation.

§divisor: Value<NumericTypes>

The second argument of the modulation.

§

InvalidRegex

A regular expression could not be parsed

Fields

§regex: String

The invalid regular expression

§message: String

Failure message from the regex engine

§

ContextNotMutable

A modification was attempted on a Context that does not allow modifications.

§

IllegalEscapeSequence(String)

An escape sequence within a string literal is illegal.

§

BuiltinFunctionsCannotBeEnabled

This context does not allow enabling builtin functions.

§

BuiltinFunctionsCannotBeDisabled

This context does not allow disabling builtin functions.

§

OutOfBoundsAccess

Out of bounds sequence access.

§

IntFromUsize

A usize was attempted to be converted to an int, but it was out of range.

Fields

§usize_int: usize

The usize that was attempted to be converted.

§

IntIntoUsize

An int was attempted to be converted to a usize, but it was out of range.

Fields

§int: NumericTypes::Int

The int that was attempted to be converted.

§

RandNotEnabled

The feature rand is not enabled, but required for the used function.

§

CustomMessage(String)

A custom error explained by its message.

Implementations§

Source§

impl<NumericTypes: EvalexprNumericTypes> EvalexprError<NumericTypes>

Source

pub fn wrong_operator_argument_amount(actual: usize, expected: usize) -> Self

Construct a WrongOperatorArgumentAmount error.

Source

pub fn wrong_function_argument_amount(actual: usize, expected: usize) -> Self

Construct a WrongFunctionArgumentAmount error for a function with a fixed amount of arguments.

Source

pub fn wrong_function_argument_amount_range( actual: usize, expected: RangeInclusive<usize>, ) -> Self

Construct a WrongFunctionArgumentAmount error for a function with a range of possible amounts of arguments.

Source

pub fn type_error(actual: Value<NumericTypes>, expected: Vec<ValueType>) -> Self

Constructs EvalexprError::TypeError{actual, expected}.

Source

pub fn wrong_type_combination( operator: Operator<NumericTypes>, actual: Vec<ValueType>, ) -> Self

Constructs EvalexprError::WrongTypeCombination{operator, actual}.

Source

pub fn expected_string(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedString{actual}.

Source

pub fn expected_int(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedInt{actual}.

Source

pub fn expected_float(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedFloat{actual}.

Source

pub fn expected_number(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedNumber{actual}.

Source

pub fn expected_number_or_string(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedNumberOrString{actual}.

Source

pub fn expected_boolean(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedBoolean{actual}.

Source

pub fn expected_tuple(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedTuple{actual}.

Source

pub fn expected_fixed_len_tuple( expected_len: usize, actual: Value<NumericTypes>, ) -> Self

Constructs EvalexprError::ExpectedFixedLenTuple{expected_len, actual}.

Source

pub fn expected_ranged_len_tuple( expected_len: RangeInclusive<usize>, actual: Value<NumericTypes>, ) -> Self

Constructs EvalexprError::ExpectedFixedLenTuple{expected_len, actual}.

Source

pub fn expected_empty(actual: Value<NumericTypes>) -> Self

Constructs EvalexprError::ExpectedEmpty{actual}.

Source

pub fn invalid_regex(regex: String, message: String) -> Self

Constructs EvalexprError::InvalidRegex(regex)

Trait Implementations§

Source§

impl<NumericTypes: Clone + EvalexprNumericTypes> Clone for EvalexprError<NumericTypes>
where NumericTypes::Int: Clone,

Source§

fn clone(&self) -> EvalexprError<NumericTypes>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<NumericTypes: Debug + EvalexprNumericTypes> Debug for EvalexprError<NumericTypes>
where NumericTypes::Int: Debug,

Source§

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

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

impl<NumericTypes: EvalexprNumericTypes> Display for EvalexprError<NumericTypes>

Source§

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

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

impl<NumericTypes: EvalexprNumericTypes> Error for EvalexprError<NumericTypes>

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<NumericTypes: PartialEq + EvalexprNumericTypes> PartialEq for EvalexprError<NumericTypes>
where NumericTypes::Int: PartialEq,

Source§

fn eq(&self, other: &EvalexprError<NumericTypes>) -> 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<NumericTypes: EvalexprNumericTypes> StructuralPartialEq for EvalexprError<NumericTypes>

Auto Trait Implementations§

§

impl<NumericTypes> Freeze for EvalexprError<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Int: Freeze, <NumericTypes as EvalexprNumericTypes>::Float: Freeze,

§

impl<NumericTypes> RefUnwindSafe for EvalexprError<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Int: RefUnwindSafe, <NumericTypes as EvalexprNumericTypes>::Float: RefUnwindSafe,

§

impl<NumericTypes> Send for EvalexprError<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Int: Send, <NumericTypes as EvalexprNumericTypes>::Float: Send,

§

impl<NumericTypes> Sync for EvalexprError<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Int: Sync, <NumericTypes as EvalexprNumericTypes>::Float: Sync,

§

impl<NumericTypes> Unpin for EvalexprError<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Int: Unpin, <NumericTypes as EvalexprNumericTypes>::Float: Unpin,

§

impl<NumericTypes> UnwindSafe for EvalexprError<NumericTypes>
where <NumericTypes as EvalexprNumericTypes>::Int: UnwindSafe, <NumericTypes as EvalexprNumericTypes>::Float: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.