diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2016-12-03 21:56:26 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2016-12-03 21:56:26 +0200 |
commit | 885618f96ab1079ee49553f46804d2a4460e41b3 (patch) | |
tree | dd2d29524ccd473a47e918a6e15a80fb8896da9a /src/num_traits.rs | |
parent | 4e55f98cac43a71f6a83aa9d81b1cb26c1745e55 (diff) |
Started adding sinusoids
Diffstat (limited to 'src/num_traits.rs')
-rw-r--r-- | src/num_traits.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/num_traits.rs b/src/num_traits.rs index 1e04cce..b6a2ac8 100644 --- a/src/num_traits.rs +++ b/src/num_traits.rs @@ -1,3 +1,5 @@ +use std; + pub trait Trig { fn sin(self) -> Self; fn cos(self) -> Self; @@ -82,3 +84,25 @@ impl_int_pow!(u8); impl_int_pow!(u16); impl_int_pow!(u32); impl_int_pow!(u64); + + +pub trait Float { + fn recip(self) -> Self; + fn PI() -> Self; +} + +macro_rules! impl_float { + ($t: ty, $pi: expr) => { + impl Float for $t { + fn recip(self) -> Self { + self.recip() + } + fn PI() -> Self { + $pi + } + } + } +} + +impl_float!(f32, std::f32::consts::PI); +impl_float!(f64, std::f64::consts::PI); |