From d368270ebce7dccd04027315dd6629d8a6d6c68e Mon Sep 17 00:00:00 2001 From: Eduard Bopp Date: Tue, 17 Feb 2015 13:45:25 +0100 Subject: [PATCH] Fix iterator mutability For loops now consume iterators. --- src/structs/dvec.rs | 10 ++-------- src/structs/dvec_macros.rs | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/structs/dvec.rs b/src/structs/dvec.rs index 1012b50b..58d7703f 100644 --- a/src/structs/dvec.rs +++ b/src/structs/dvec.rs @@ -68,14 +68,8 @@ impl DVec { impl FromIterator for DVec { #[inline] - fn from_iter>(mut param: I) -> DVec { - let mut res = DVec { at: Vec::new() }; - - for e in param { - res.at.push(e) - } - - res + fn from_iter>(param: I) -> DVec { + DVec { at: param.collect() } } } diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index 27aa357c..056a4640 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -497,7 +497,7 @@ macro_rules! small_dvec_from_impl ( impl FromIterator for $dvec { #[inline] - fn from_iter>(mut param: I) -> $dvec { + fn from_iter>(param: I) -> $dvec { let mut at: [N; $dim] = [ $( $zeros, )* ]; let mut dim = 0;