From d8db04cce5a2a94505bd2c43ee0ac7bd6176341b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Fri, 16 Aug 2013 18:08:51 +0200 Subject: [PATCH] Changed the UniformSphereSample trait to return a borrowed vector. --- src/traits/sample.rs | 10 +--------- src/vec_spec.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) 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 + } }