diff --git a/src/traits/sample.rs b/src/traits/sample.rs index 06ff677c..e44e0cad 100644 --- a/src/traits/sample.rs +++ b/src/traits/sample.rs @@ -5,13 +5,5 @@ pub trait UniformSphereSample { fn sample(&fn(&'static Self)); /// Gets the list of all samples. - fn sample_list() -> ~[&'static Self] { - let mut res = ~[]; - - do UniformSphereSample::sample:: |s| { - res.push(s) - } - - res - } + fn sample_list() -> &[Self]; } diff --git a/src/vec_spec.rs b/src/vec_spec.rs index a466a579..3859fe92 100644 --- a/src/vec_spec.rs +++ b/src/vec_spec.rs @@ -149,6 +149,13 @@ impl UniformSphereSample for Vec2 { f(sample) } } + + #[inline] + fn sample_list() -> &[Vec2] { + let res: &[Vec2] = SAMPLES_2_F64; + + res + } } impl UniformSphereSample for Vec3 { @@ -158,4 +165,11 @@ impl UniformSphereSample for Vec3 { f(sample) } } + + #[inline] + fn sample_list() -> &[Vec3] { + let res: &[Vec3] = SAMPLES_3_F64; + + res + } }