Skip to content

Commit

Permalink
Use common Rust naming convention for Target enum
Browse files Browse the repository at this point in the history
This is would be a breaking change if it was in the library side of
things but it's in the binary side (`main.rs`) so it shouldn't be
a breaking change.
  • Loading branch information
xoen committed Sep 30, 2024
1 parent 2f9f6f9 commit b99c848
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ struct Args {

enum Target {
// NATIONAL,
POSTCODE,
REGION,
Postcode,
Region,
}

impl FromStr for Target {
Expand All @@ -36,8 +36,8 @@ impl FromStr for Target {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
//"" => Ok(Target::NATIONAL),
_ if s.parse::<u8>().is_ok() => Ok(Target::REGION),
_ => Ok(Target::POSTCODE),
_ if s.parse::<u8>().is_ok() => Ok(Target::Region),
_ => Ok(Target::Postcode),
}
}
}
Expand All @@ -54,25 +54,25 @@ async fn main() {
let end_date: Option<&str> = args.end_date.as_deref();

match target {
Target::POSTCODE => {
Target::Postcode => {
let result =
get_intensities_postcode(args.value.as_str(), start_date, &end_date).await;
handle_results(result);
}
Target::REGION => {
Target::Region => {
let id: u8 = args.value.parse::<u8>().unwrap();
let result = get_intensities_region(id, start_date, &end_date).await;
handle_results(result);
}
}
} else {
match target {
Target::POSTCODE => {
Target::Postcode => {
let postcode = args.value.as_str();
let result = get_intensity_postcode(postcode).await;
handle_result(result, "postcode", postcode);
}
Target::REGION => {
Target::Region => {
let id: u8 = args.value.parse::<u8>().unwrap();
let result = get_intensity_region(id).await;
handle_result(result, "region", id.to_string().as_str());
Expand Down

0 comments on commit b99c848

Please sign in to comment.