File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -45,18 +45,21 @@ impl<R: 'static> Registry<R> {
4545 self . list . push ( data) ;
4646 }
4747
48+ fn find_data ( & self , name : & str ) -> ValidationResult < Arc < RegistrantData < R > > > {
49+ return match self . map . get ( name) {
50+ None => ValidationError :: message ( format ! ( "No implementation named {}" , name) ) ,
51+ Some ( data) => Result :: Ok ( data. clone ( ) ) ,
52+ } ;
53+ }
54+
4855 pub fn find ( & self , name : & str , args : & [ & str ] ) -> ValidationResult < R > {
49- match self . map . get ( name) {
50- None => {
51- return ValidationError :: message ( format ! ( "No implementation named {}" , name) ) ;
52- }
53- Some ( data) => {
54- if args. len ( ) != data. argct {
55- return ValidationError :: message ( format ! ( "Wrong number of args for {}" , name) ) ;
56- }
57- return ( data. init ) ( args) ;
58- }
56+ let data = self . find_data ( name) ?;
57+
58+ if args. len ( ) != data. argct {
59+ return ValidationError :: message ( format ! ( "Wrong number of args for {}" , name) ) ;
5960 }
61+
62+ return ( data. init ) ( args) ;
6063 }
6164
6265 pub fn labelled_multiple_options ( & ' static self , prefixes : & [ & str ] ) -> OptionsPile < Vec < ( String , R ) > > {
You can’t perform that action at this time.
0 commit comments