@@ -13,6 +13,7 @@ use std::io::prelude::*;
1313use std:: path:: Path ;
1414
1515use fnv:: FnvHashMap ;
16+ use itertools:: Itertools ;
1617use subst:: VariableMap ;
1718use toml:: { Table , Value } ;
1819
@@ -50,7 +51,7 @@ impl LibraryConfig {
5051 } ;
5152
5253 if is_literal ( stripped_pattern) {
53- let file_path = Path :: new ( pattern) . to_owned ( ) ;
54+ let file_path = PathBuf :: from ( pattern) ;
5455
5556 if file_path. exists ( ) {
5657 result. push ( file_path) ;
@@ -86,20 +87,8 @@ impl LibraryConfig {
8687 }
8788 }
8889 }
89- Self :: remove_duplicates ( result)
90- }
91-
92- /// Remove duplicate file names from the result
93- fn remove_duplicates ( file_names : Vec < PathBuf > ) -> Vec < PathBuf > {
94- let mut result = Vec :: with_capacity ( file_names. len ( ) ) ;
95- let mut fileset = std:: collections:: HashSet :: new ( ) ;
96-
97- for file_name in file_names. into_iter ( ) {
98- if fileset. insert ( file_name. clone ( ) ) {
99- result. push ( file_name) ;
100- }
101- }
102- result
90+ // Remove duplicate file names from the result
91+ result. into_iter ( ) . unique ( ) . collect ( )
10392 }
10493
10594 /// Returns the name of the library
@@ -412,15 +401,7 @@ where
412401
413402/// Returns true if the pattern is a plain file name and not a glob pattern
414403fn is_literal ( pattern : & str ) -> bool {
415- for chr in pattern. chars ( ) {
416- match chr {
417- '?' | '*' | '[' => {
418- return false ;
419- }
420- _ => { }
421- }
422- }
423- true
404+ !pattern. chars ( ) . any ( |chr| matches ! ( & chr, '?' | '*' | '[' ) )
424405}
425406
426407#[ cfg( test) ]
0 commit comments