From b88c0fdd42e8adf2df4b94b8d188807e72992e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 27 Mar 2017 12:47:02 +0200 Subject: [PATCH] style: Use .iter().map instead of manual loop in counter code. --- .../style/properties/longhand/counters.mako.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index 8e74d192ea18..edc7e6927d8b 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -289,19 +289,15 @@ type ComputedValue = computed_value::T; fn to_computed_value(&self, context: &Context) -> Self::ComputedValue { - let mut ret = Vec::with_capacity(self.0.len()); - for entry in &self.0 { - ret.push((entry.0.clone(), entry.1.to_computed_value(context))); - } - computed_value::T(ret) + computed_value::T(self.0.iter().map(|entry| { + (entry.0.clone(), entry.1.to_computed_value(context)) + }).collect::>()) } fn from_computed_value(computed: &Self::ComputedValue) -> Self { - let mut ret = Vec::with_capacity(computed.0.len()); - for entry in &computed.0 { - ret.push((entry.0.clone(), specified::Integer::from_computed_value(&entry.1))); - } - SpecifiedValue(ret) + SpecifiedValue(computed.0.iter().map(|entry| { + (entry.0.clone(), specified::Integer::from_computed_value(&entry.1)) + }).collect::>()) } }