Commit Diff


commit - 2faee61fc98beef13f9c776245be39b6db9d9e83
commit + 7d23791440375f91c6bb9d5f8bc9c095f92d1dea
blob - 6afab67ab3cb103a11271dc0c786941db099bff7
blob + b8a6d50341e20bb73c73fcc78d045697fde7eef9
--- src/api_query.rs
+++ src/api_query.rs
@@ -1,13 +1,13 @@
 use std::collections::HashMap;
 
-#[allow(non_snake_case)]
+#[allow(non_snake_case, dead_code)]
 #[derive(serde::Deserialize, Debug)]
 struct APIResponse {
     data: HashMap<String, DataResponse>,
     meta: MetaResponse,
 }
 
-#[allow(non_snake_case)]
+#[allow(non_snake_case, dead_code)]
 #[derive(serde::Deserialize, Debug)]
 struct DataResponse {
     ags: String,
@@ -26,7 +26,7 @@ struct DataResponse {
     delta: DeltaResponse,
 }
 
-#[allow(non_snake_case)]
+#[allow(non_snake_case, dead_code)]
 #[derive(serde::Deserialize, Debug)]
 struct DeltaResponse {
     cases: i32,
@@ -34,7 +34,7 @@ struct DeltaResponse {
     recovered: i32,
 }
 
-#[allow(non_snake_case)]
+#[allow(non_snake_case, dead_code)]
 #[derive(serde::Deserialize, Debug)]
 struct MetaResponse {
     source: String,
@@ -46,9 +46,9 @@ struct MetaResponse {
 
 const API_STRING: &str = "https://api.corona-zahlen.org//districts/";
 
-async fn get_specific_disctrict(district: &String) -> Result<APIResponse, String> {
+async fn get_specific_disctrict(district: &str) -> Result<APIResponse, String> {
     let mut query_str: String = API_STRING.to_owned();
-    query_str.push_str(&district);
+    query_str.push_str(district);
 
     let resp = match reqwest::get(query_str).await {
         Ok(r) => r,
@@ -62,7 +62,7 @@ async fn get_specific_disctrict(district: &String) -> 
         }
     };
 
-    return Ok(res);
+    Ok(res)
 }
 
 pub async fn get_all_district_info(districts: &Vec<String>) -> Result<String, String> {
blob - 5f153b98743af53e0877d2d06e255a45e6d8aa9d
blob + d4016f708c3a120e624e1484b00b81434287f620
--- src/main.rs
+++ src/main.rs
@@ -1,9 +1,4 @@
-use serenity::{
-    http::client::Http,
-    model::{
-        id::ChannelId,
-    },
-};
+use serenity::{http::client::Http, model::id::ChannelId};
 
 use std::env;
 
@@ -14,7 +9,7 @@ async fn main() {
     let token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN environment variable");
     let channel_id = env::var("CHANNEL_ID").expect("Missing CHANNEL_ID environment variable");
     let districts_env = env::var("DISTRICTS").expect("Missing DISTRICTS environment variable");
-    let districts: Vec<String> = districts_env.split(",").map(|s| s.to_string()).collect();
+    let districts: Vec<String> = districts_env.split(',').map(|s| s.to_string()).collect();
 
     let msg = match api_query::get_all_district_info(&districts).await {
         Ok(k) => {
@@ -23,14 +18,20 @@ async fn main() {
             s.push_str("```");
 
             s
-        },
+        }
         Err(e) => {
             println!("{:?}", e);
             std::process::exit(1);
-        },
+        }
     };
 
     let http = Http::new_with_token(&token);
-    let cid = ChannelId(channel_id.parse::<u64>().expect("CHANNEL_ID not an unsigned integer"));
-    cid.send_message(&http, |m| m.content(msg)).await.expect(format!("Failed sending message to channel {}", cid));
+    let cid = ChannelId(
+        channel_id
+            .parse::<u64>()
+            .expect("CHANNEL_ID not an unsigned integer"),
+    );
+    cid.send_message(&http, |m| m.content(msg))
+        .await
+        .expect("Failed sending message to channel");
 }