File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed
Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -132,8 +132,7 @@ impl<'cmd> Validator<'cmd> {
132132 }
133133
134134 debug ! ( "Validator::build_conflict_err: name={name:?}" ) ;
135- let mut seen = FlatSet :: new ( ) ;
136- let conflicts = conflict_ids
135+ let conflict_ids = conflict_ids
137136 . iter ( )
138137 . flat_map ( |c_id| {
139138 if self . cmd . find_group ( c_id) . is_some ( ) {
@@ -142,16 +141,18 @@ impl<'cmd> Validator<'cmd> {
142141 vec ! [ c_id. clone( ) ]
143142 }
144143 } )
145- . filter_map ( |c_id| {
146- seen. insert ( c_id. clone ( ) ) . then ( || {
147- let c_arg = self . cmd . find ( & c_id) . expect ( INTERNAL_ERROR_MSG ) ;
148- c_arg. to_string ( )
149- } )
144+ . collect :: < FlatSet < _ > > ( )
145+ . into_vec ( ) ;
146+ let conflicts = conflict_ids
147+ . iter ( )
148+ . map ( |c_id| {
149+ let c_arg = self . cmd . find ( & c_id) . expect ( INTERNAL_ERROR_MSG ) ;
150+ c_arg. to_string ( )
150151 } )
151152 . collect ( ) ;
152153
153154 let former_arg = self . cmd . find ( name) . expect ( INTERNAL_ERROR_MSG ) ;
154- let usg = self . build_conflict_err_usage ( matcher, conflict_ids) ;
155+ let usg = self . build_conflict_err_usage ( matcher, & conflict_ids) ;
155156 Err ( Error :: argument_conflict (
156157 self . cmd ,
157158 former_arg. to_string ( ) ,
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ impl<T: PartialEq + Eq> FlatSet<T> {
6060 {
6161 self . inner . sort_by_key ( f) ;
6262 }
63+
64+ pub ( crate ) fn into_vec ( self ) -> Vec < T > {
65+ self . inner
66+ }
6367}
6468
6569impl < T : PartialEq + Eq > Default for FlatSet < T > {
Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ error: the argument '--conflict' cannot be used with:
232232 --a
233233 --b
234234
235- Usage: prog --a -- conflict
235+ Usage: prog --conflict
236236
237237For more information, try '--help'.
238238
You can’t perform that action at this time.
0 commit comments