From 7643a24cc1659d92952a95be8c1d6412bf94c13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Violeta=20Hern=C3=A1ndez?= Date: Thu, 17 Jun 2021 02:44:06 -0500 Subject: [PATCH] `Result<(), ()>` to `bool` (#916) --- src/linalg/pow.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/linalg/pow.rs b/src/linalg/pow.rs index 33759a90..74da2cfe 100644 --- a/src/linalg/pow.rs +++ b/src/linalg/pow.rs @@ -18,23 +18,22 @@ where { /// Attempts to raise this matrix to an integral power `e` in-place. If this /// matrix is non-invertible and `e` is negative, it leaves this matrix - /// untouched and returns `Err(())`. Otherwise, it returns `Ok(())` and + /// untouched and returns `false`. Otherwise, it returns `true` and /// overwrites this matrix with the result. - #[must_use] - pub fn pow_mut(&mut self, mut e: I) -> Result<(), ()> { + pub fn pow_mut(&mut self, mut e: I) -> bool { let zero = I::zero(); // A matrix raised to the zeroth power is just the identity. if e == zero { self.fill_with_identity(); - return Ok(()); + return true; } // If e is negative, we compute the inverse matrix, then raise it to the // power of -e. if e < zero { if !self.try_inverse_mut() { - return Err(()); + return false; } } @@ -58,7 +57,7 @@ where multiplier.copy_from(&buf); if e == zero { - return Ok(()); + return true; } } } @@ -77,9 +76,10 @@ where pub fn pow(&self, e: I) -> Option> { let mut clone = self.clone_owned(); - match clone.pow_mut(e) { - Ok(()) => Some(clone), - Err(()) => None, + if clone.pow_mut(e) { + Some(clone) + } else { + None } } }