1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Contains all the traits that control the usage of the "free functions".
//!
//! You should never need to import anything here yourself.
//!
//! All of the free functions in this crate should "just work" without extra
//! effort on your part.

use super::*;

/// Things that support an "absolute value" operation.
///
/// * Free Function: [`abs`](crate::abs)
pub trait CanAbs {
  /// Computes the absolute value.
  fn abs(self) -> Self;
}
macro_rules! impl_CanAbs {
  ($t:ty) => {
    impl CanAbs for $t {
      fn abs(self) -> Self {
        Self::abs(self)
      }
    }
  };
}
impl_CanAbs!(i8);
impl_CanAbs!(i16);
impl_CanAbs!(i32);
impl_CanAbs!(i64);
impl_CanAbs!(i128);
impl_CanAbs!(isize);
impl CanAbs for f32 {
  fn abs(self) -> Self {
    lokacore::abs_f32(self)
  }
}
impl CanAbs for f64 {
  fn abs(self) -> Self {
    lokacore::abs_f64(self)
  }
}
impl_CanAbs!(Vec2);
impl_CanAbs!(Vec3);
impl_CanAbs!(Vec4);