noise_functions/
value_or_noise.rs

1use crate::{Constant, Noise};
2
3/// Either a `f32` or a noise.
4///
5/// Used for [`Noise`] modifier methods.
6pub trait ValueOrNoise {
7    type Noise;
8    fn into_noise(self) -> Self::Noise;
9}
10
11impl ValueOrNoise for f32 {
12    type Noise = Constant;
13
14    fn into_noise(self) -> Self::Noise {
15        Constant(self)
16    }
17}
18
19impl<N: Noise> ValueOrNoise for N {
20    type Noise = Self;
21
22    fn into_noise(self) -> Self::Noise {
23        self
24    }
25}