Skip to content

Commit

Permalink
Add inline to powi
Browse files Browse the repository at this point in the history
  • Loading branch information
paholg committed Mar 12, 2021
1 parent 72f4f52 commit 4baa893
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.
- [fixed] `op` macro with 2018 edition import.
- [changed] Allowed calling `assert_type_eq` and `assert_type` at top level.
- [added] Marker trait `Zero` for `Z0`, `U0`, and `B0`.

- [added] Implementation of `Pow` trait for f32 and f64 with negative exponent

### 1.12.0 (2020-04-13)
Expand Down
6 changes: 5 additions & 1 deletion src/type_operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ macro_rules! impl_pow_f {
impl<U: Unsigned + NonZero> Pow<NInt<U>> for $t {
type Output = $t;

#[inline]
fn powi(self, _: NInt<U>) -> Self::Output {
<$t as Pow<PInt<U>>>::powi(self, PInt::new()).recip()
}
Expand Down Expand Up @@ -257,7 +258,10 @@ fn pow_test() {
if *$x == 0.0 {
assert!(<$f as Pow<N3>>::powi(*$x, n3).is_infinite());
} else {
assert!((<$f as Pow<N3>>::powi(*$x, n3) - 1. / $x / $x / $x).abs() < ::core::$f::EPSILON);
assert!(
(<$f as Pow<N3>>::powi(*$x, n3) - 1. / $x / $x / $x).abs()
< ::core::$f::EPSILON
);
}
};
}
Expand Down

0 comments on commit 4baa893

Please sign in to comment.