diff options
| author | Kevin Butler <haqkrs@gmail.com> | 2015-02-13 07:33:44 +0000 |
|---|---|---|
| committer | Kevin Butler <haqkrs@gmail.com> | 2015-02-18 00:56:07 +0000 |
| commit | 2f586b9687e5c33d9d3b8eccfc309f65d2a9f4e9 (patch) | |
| tree | 578e2d49b5c8b71d7c38142adcf6d10dba09d690 /src/libsyntax/parse/parser.rs | |
| parent | 5705d48e280f8a0065c214edfb3dcdcecc323316 (diff) | |
| download | rust-2f586b9687e5c33d9d3b8eccfc309f65d2a9f4e9.tar.gz rust-2f586b9687e5c33d9d3b8eccfc309f65d2a9f4e9.zip | |
Opt for .cloned() over .map(|x| x.clone()) etc.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 9 |
1 files changed, 4 insertions, 5 deletions
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<Attribute>, rhs: Option<Vec<Attribute>>) -> Vec<Attribute> { - 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::<Vec<_>>(); + let mut expected = edible.iter().cloned().collect::<Vec<_>>(); 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::<Vec<_>>(); + let mut expected = edible.iter().cloned().collect::<Vec<_>>(); expected.push_all(&inedible[]); self.check_for_erroneous_unit_struct_expecting( &expected[]); |
