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:
ConversionErroris thrown if a conversion between types is not possible.DivisionByZeroErroris thrown if it is tried to perform a division by0.InvalidExponentis thrown if an invalid exponent is used for apowfunction.InvalidIntegerInputis thrown if an integer input is provided as parameter that does not meet the conditions of that function.InvalidIntervalis thrown if an invalid interval, e.g. of negative size, is provided.InvalidModulusis thrown if an integer is provided, which is smaller than2.NulErroris thrown if aNulErroris thrown, which currently only happens if an invalid string is given to construct aCString.MismatchingMatrixDimensionis thrown if arithmetic is done with matrices of mismatching dimensions.MismatchingModulusis thrown if any function is called on two objects with different modulus where equal modulus is required.NonPositiveis thrown if the function expects a positive number, but a number smaller than1is provided.NoSquareMatrixis thrown if a matrix is not square.OutOfBoundsis thrown if a provided index is not in a desired range.VectorFunctionCalledOnNonVectoris 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 Error for MathError
impl Error for MathError
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<StringConversionError> for MathError
impl From<StringConversionError> for MathError
Source§fn from(source: StringConversionError) -> Self
fn from(source: StringConversionError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for MathError
impl RefUnwindSafe for MathError
impl Send for MathError
impl Sync for MathError
impl Unpin for MathError
impl UnwindSafe for MathError
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