From c14943270bbc037aefd7a48f0c9fd054923c2b8f Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Mon, 5 Sep 2022 18:54:20 -0400 Subject: [PATCH] Fix clippy errors --- src/github_api.rs | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/github_api.rs b/src/github_api.rs index 2898371..8c37394 100644 --- a/src/github_api.rs +++ b/src/github_api.rs @@ -3,8 +3,8 @@ use colored::*; use serde::Deserialize; enum IncidentType { - ALL, - UNRESOLVED, + All, + Unresolved, } #[derive(Deserialize, Debug)] @@ -244,26 +244,21 @@ pub struct IncidentInfo { impl IncidentInfo { fn get_incidents(incident_type: IncidentType) -> Result { - let result: IncidentInfo; - - match incident_type { - IncidentType::ALL => { - result = - reqwest::blocking::get("https://www.githubstatus.com/api/v2/incidents.json")? - .json::()?; - } - IncidentType::UNRESOLVED => { - result = reqwest::blocking::get( - "https://www.githubstatus.com/api/v2/incidents/unresolved.json", - )? - .json::()?; + let result: IncidentInfo = match incident_type { + IncidentType::All => { + reqwest::blocking::get("https://www.githubstatus.com/api/v2/incidents.json")? + .json::()? } - } + IncidentType::Unresolved => reqwest::blocking::get( + "https://www.githubstatus.com/api/v2/incidents/unresolved.json", + )? + .json::()?, + }; Ok(result) } - fn print(self: Self) { + fn print(self) { if self.incidents.is_empty() { println!("No unresolved incidents reported"); println!(); @@ -315,7 +310,7 @@ impl IncidentInfo { } pub fn print_all() { - let info = IncidentInfo::get_incidents(IncidentType::ALL); + let info = IncidentInfo::get_incidents(IncidentType::All); match info { Ok(i) => IncidentInfo::print(i), @@ -324,7 +319,7 @@ impl IncidentInfo { } pub fn print_unresolved() { - let info = IncidentInfo::get_incidents(IncidentType::UNRESOLVED); + let info = IncidentInfo::get_incidents(IncidentType::Unresolved); match info { Ok(i) => IncidentInfo::print(i),