rust_matrix/
pow.rs

1/// A trait created to represent raising an element
2/// to a given power.
3/// This explicitly relies on the `powf` trait
4/// and thus will only work for types that implement
5/// that trait
6pub trait Pow {
7    fn pow(&self, n: Self) -> Self;
8}
9
10macro_rules! impl_pow {
11    ( $($ty:ty),* ) => {
12        $(
13            impl Pow for $ty {
14                fn pow(&self, n: Self) -> Self {
15                    self.powf(n)
16                }
17            }
18        )*
19    };
20}
21
22impl_pow!(f64, f32);