diff options
| author | Ms2ger <ms2ger@gmail.com> | 2015-01-24 19:13:36 +0100 |
|---|---|---|
| committer | Ms2ger <ms2ger@gmail.com> | 2015-01-28 09:39:28 +0100 |
| commit | f88c94d8d2c74402d6f72607a47c4850dcdf3b4d (patch) | |
| tree | eed649a437caae9d7adfc7eedb0c6927bd52ba42 /src/libsyntax | |
| parent | d0a9a39b1eb6a5fd152332392b7c4b1cd08a92c6 (diff) | |
| download | rust-f88c94d8d2c74402d6f72607a47c4850dcdf3b4d.tar.gz rust-f88c94d8d2c74402d6f72607a47c4850dcdf3b4d.zip | |
Simplify the implementation of segments_name_eq.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 5aeea47ac60..07d3290d410 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -670,20 +670,13 @@ pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool { // are two arrays of segments equal when compared unhygienically? pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> bool { - if a.len() != b.len() { - false - } else { - for (idx,seg) in a.iter().enumerate() { - if seg.identifier.name != b[idx].identifier.name - // FIXME #7743: ident -> name problems in lifetime comparison? - // can types contain idents? - || seg.parameters != b[idx].parameters - { - return false; - } - } - true - } + a.len() == b.len() && + a.iter().zip(b.iter()).all(|(s, t)| { + s.identifier.name == t.identifier.name && + // FIXME #7743: ident -> name problems in lifetime comparison? + // can types contain idents? + s.parameters == t.parameters + }) } /// Returns true if this literal is a string and false otherwise. |
