Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
*DS_Store*
*.swp
*.iml
__MACOSX
__MACOSX
18 changes: 10 additions & 8 deletions smarty-rust-sdk/src/us_street_api/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Lookup {
#[serde(rename = "format")]
pub format_output: OutputFormat,

pub county_source: CountySource,
pub county_source: Option<CountySource>,

#[serde(skip_serializing)]
pub results: Candidates,
Expand Down Expand Up @@ -79,7 +79,7 @@ impl Lookup {
max_candidates_string = 5.to_string();
}

vec![
let mut res = vec![
has_param("street".to_string(), self.street),
has_param("street2".to_string(), self.street2),
has_param("secondary".to_string(), self.secondary),
Expand All @@ -93,11 +93,13 @@ impl Lookup {
has_param("candidates".to_string(), max_candidates_string),
has_param("match".to_string(), self.match_strategy.to_string()),
has_param("format".to_string(), self.format_output.to_string()),
has_param("county_source".to_string(), self.county_source.to_string()),
]
.iter()
.filter_map(Option::clone)
.collect::<Vec<_>>()
];

if let Some(source) = self.county_source {
res.push(Some(("country_source".to_string(), source.to_string())));
}

res.iter().filter_map(Option::clone).collect::<Vec<_>>()
}
}

Expand Down Expand Up @@ -165,4 +167,4 @@ impl Display for CountySource {
}
}
}
}
}