pbrt_r3/core/geometry/
numeric_traits.rs

1pub trait NumberType {
2    fn abs(x: Self) -> Self;
3}
4impl NumberType for f32 {
5    fn abs(x: Self) -> Self {
6        Self::abs(x)
7    }
8}
9impl NumberType for f64 {
10    fn abs(x: Self) -> Self {
11        Self::abs(x)
12    }
13}
14impl NumberType for i32 {
15    fn abs(x: Self) -> Self {
16        Self::abs(x)
17    }
18}
19
20pub trait FloatType {
21    fn sqrt(x: Self) -> Self;
22}
23impl FloatType for f32 {
24    fn sqrt(x: Self) -> Self {
25        Self::sqrt(x)
26    }
27}
28impl FloatType for f64 {
29    fn sqrt(x: Self) -> Self {
30        Self::sqrt(x)
31    }
32}