@@ -38,7 +38,7 @@ pub struct Lookup {
3838 #[ serde( rename = "format" ) ]
3939 pub format_output : OutputFormat ,
4040
41- pub county_source : CountySource ,
41+ pub county_source : Option < CountySource > ,
4242
4343 #[ serde( skip_serializing) ]
4444 pub results : Candidates ,
@@ -79,7 +79,7 @@ impl Lookup {
7979 max_candidates_string = 5 . to_string ( ) ;
8080 }
8181
82- vec ! [
82+ let mut res = vec ! [
8383 has_param( "street" . to_string( ) , self . street) ,
8484 has_param( "street2" . to_string( ) , self . street2) ,
8585 has_param( "secondary" . to_string( ) , self . secondary) ,
@@ -93,11 +93,13 @@ impl Lookup {
9393 has_param( "candidates" . to_string( ) , max_candidates_string) ,
9494 has_param( "match" . to_string( ) , self . match_strategy. to_string( ) ) ,
9595 has_param( "format" . to_string( ) , self . format_output. to_string( ) ) ,
96- has_param( "county_source" . to_string( ) , self . county_source. to_string( ) ) ,
97- ]
98- . iter ( )
99- . filter_map ( Option :: clone)
100- . collect :: < Vec < _ > > ( )
96+ ] ;
97+
98+ if let Some ( source) = self . county_source {
99+ res. push ( Some ( ( "country_source" . to_string ( ) , source. to_string ( ) ) ) ) ;
100+ }
101+
102+ res. iter ( ) . filter_map ( Option :: clone) . collect :: < Vec < _ > > ( )
101103 }
102104}
103105
@@ -165,4 +167,4 @@ impl Display for CountySource {
165167 }
166168 }
167169 }
168- }
170+ }
0 commit comments