From 2f586b9687e5c33d9d3b8eccfc309f65d2a9f4e9 Mon Sep 17 00:00:00 2001 From: Kevin Butler Date: Fri, 13 Feb 2015 07:33:44 +0000 Subject: Opt for .cloned() over .map(|x| x.clone()) etc. --- src/libsyntax/parse/parser.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 407740e580d..f14cd524776 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -240,9 +240,8 @@ macro_rules! maybe_whole { fn maybe_append(mut lhs: Vec, rhs: Option>) -> Vec { - match rhs { - Some(ref attrs) => lhs.extend(attrs.iter().map(|a| a.clone())), - None => {} + if let Some(ref attrs) = rhs { + lhs.extend(attrs.iter().cloned()) } lhs } @@ -467,7 +466,7 @@ impl<'a> Parser<'a> { debug!("commit_expr {:?}", e); if let ExprPath(..) = e.node { // might be unit-struct construction; check for recoverableinput error. - let mut expected = edible.iter().map(|x| x.clone()).collect::>(); + let mut expected = edible.iter().cloned().collect::>(); expected.push_all(inedible); self.check_for_erroneous_unit_struct_expecting(&expected[]); } @@ -485,7 +484,7 @@ impl<'a> Parser<'a> { if self.last_token .as_ref() .map_or(false, |t| t.is_ident() || t.is_path()) { - let mut expected = edible.iter().map(|x| x.clone()).collect::>(); + let mut expected = edible.iter().cloned().collect::>(); expected.push_all(&inedible[]); self.check_for_erroneous_unit_struct_expecting( &expected[]); -- cgit 1.4.1-3-g733a5