[][src]Module evalexpr::error

The error module contains the Error enum that contains all error types used by this crate.

The Error enum implements constructors for its struct variants, because those are ugly to construct.

The module also contains some helper functions starting with expect_ that check for a condition and return Err(_) if the condition is not fulfilled. They are meant as shortcuts to not write the same error checking code everywhere.

Enums

EvalexprError

Errors used in this crate.

Functions

expect_boolean

Returns Ok(bool) if the given value is a Value::Boolean, or Err(Error::ExpectedBoolean) otherwise.

expect_function_argument_amount

Returns Ok(()) if the actual and expected parameters are equal, and Err(Error::WrongFunctionArgumentAmount) otherwise.

expect_number

Returns Ok(()) if the given value is numeric. Numeric types are Value::Int and Value::Float. Otherwise, Err(Error::ExpectedNumber) is returned.

expect_number_or_string

Returns Ok(()) if the given value is a string or a numeric

expect_string

Returns Ok(&str) if the given value is a Value::String, or Err(Error::ExpectedString) otherwise.

Type Definitions

EvalexprResult

Standard result type used by this crate.