MathError

Enum MathError 

Source
pub enum MathError {
Show 14 variants ConversionError(String), DivisionByZeroError(String), InvalidExponent(String), InvalidIntegerInput(String), InvalidInterval(String), InvalidModulus(String), NulError(NulError), MismatchingMatrixDimension(String), MismatchingModulus(String), NonPositive(String), NoSquareMatrix(String), OutOfBounds(String, String), StringConversionError(StringConversionError), VectorFunctionCalledOnNonVector(String, i64, i64),
}
Expand description

MathError defines this crate’s error enum, which can hold all sorts of errors occurring in this crate.

Implemented error types:

  • ConversionError is thrown if a conversion between types is not possible.
  • DivisionByZeroError is thrown if it is tried to perform a division by 0.
  • InvalidExponent is thrown if an invalid exponent is used for a pow function.
  • InvalidIntegerInput is thrown if an integer input is provided as parameter that does not meet the conditions of that function.
  • InvalidInterval is thrown if an invalid interval, e.g. of negative size, is provided.
  • InvalidModulus is thrown if an integer is provided, which is smaller than 2.
  • NulError is thrown if a NulError is thrown, which currently only happens if an invalid string is given to construct a CString.
  • MismatchingMatrixDimension is thrown if arithmetic is done with matrices of mismatching dimensions.
  • MismatchingModulus is thrown if any function is called on two objects with different modulus where equal modulus is required.
  • NonPositive is thrown if the function expects a positive number, but a number smaller than 1 is provided.
  • NoSquareMatrix is thrown if a matrix is not square.
  • OutOfBounds is thrown if a provided index is not in a desired range.
  • VectorFunctionCalledOnNonVector is thrown if a function defined on vectors was called on a matrix instance that is not a vector.

§Examples

use qfall_math::{error::MathError, rational::Q};
use std::str::FromStr;

fn parse_string_to_q() -> Result<(), MathError> {
    let text = "2/0";
    let q = Q::from_str(text)?;
    return Ok(());
}

Variants§

§

ConversionError(String)

Conversion error.

§

DivisionByZeroError(String)

Division by zero error.

§

InvalidExponent(String)

Invalid exponent.

§

InvalidIntegerInput(String)

Invalid integer was input to a specific function.

§

InvalidInterval(String)

Invalid interval provided.

§

InvalidModulus(String)

Parse int to modulus error.

§

NulError(NulError)

Converts a NulError, which currently only happens if an invalid string is given to construct a CString.

§

MismatchingMatrixDimension(String)

Mismatching matrix dimension error.

§

MismatchingModulus(String)

Mismatching modulus error.

§

NonPositive(String)

If an integer is not a positive number.

§

NoSquareMatrix(String)

If a matrix is not square.

§

OutOfBounds(String, String)

If a provided index is out of bounds.

§

StringConversionError(StringConversionError)

Some string to one of our data-types error occurred.

§

VectorFunctionCalledOnNonVector(String, i64, i64)

If a function defined on vectors is called on a matrix that is not a vector.

Trait Implementations§

Source§

impl Debug for MathError

Source§

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

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

impl Display for MathError

Source§

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

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

impl Error for MathError

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 From<NulError> for MathError

Source§

fn from(source: NulError) -> Self

Converts to this type from the input type.
Source§

impl From<StringConversionError> for MathError

Source§

fn from(source: StringConversionError) -> Self

Converts to this type from the input type.

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V