noise_functions/
sample.rs1use crate::Noise;
2
3pub trait Sample<const DIM: usize, Point = [f32; DIM]>: Noise {
5 fn sample_with_seed(&self, point: Point, seed: i32) -> f32;
6}
7
8impl<const DIM: usize, Point, N> Sample<DIM, Point> for &N
9where
10 N: Sample<DIM, Point>,
11{
12 #[inline(always)]
13 fn sample_with_seed(&self, point: Point, seed: i32) -> f32 {
14 N::sample_with_seed(self, point, seed)
15 }
16}
17
18#[cfg(feature = "alloc")]
19impl<const DIM: usize, Point> Sample<DIM, Point> for alloc::boxed::Box<dyn Sample<DIM, Point>>
20where
21 Self: Noise,
22{
23 fn sample_with_seed(&self, point: Point, seed: i32) -> f32 {
24 (**self).sample_with_seed(point, seed)
25 }
26}