Add MathOp helper methods
It's helpful to be able to assert what type of Math error occurred.
This commit is contained in:
parent
41f26cf090
commit
2f7e74da45
|
@ -254,6 +254,18 @@ impl MathOp {
|
||||||
|
|
||||||
/// Returns `true` if this operation error'ed due to division by zero.
|
/// Returns `true` if this operation error'ed due to division by zero.
|
||||||
pub fn is_div_by_zero(self) -> bool { !self.is_overflow() }
|
pub fn is_div_by_zero(self) -> bool { !self.is_overflow() }
|
||||||
|
|
||||||
|
/// Returns `true` if this operation error'ed due to addition.
|
||||||
|
pub fn is_addition(self) -> bool { self == MathOp::Add }
|
||||||
|
|
||||||
|
/// Returns `true` if this operation error'ed due to subtraction.
|
||||||
|
pub fn is_subtraction(self) -> bool { self == MathOp::Sub }
|
||||||
|
|
||||||
|
/// Returns `true` if this operation error'ed due to multiplication.
|
||||||
|
pub fn is_multiplication(self) -> bool { self == MathOp::Mul }
|
||||||
|
|
||||||
|
/// Returns `true` if this operation error'ed due to negation.
|
||||||
|
pub fn is_negation(self) -> bool { self == MathOp::Neg }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for MathOp {
|
impl fmt::Display for MathOp {
|
||||||
|
|
Loading…
Reference in New Issue