From 5170cd53435b8665b2db17e49d2cea140dc4d458 Mon Sep 17 00:00:00 2001 From: Hannes Kuchelmeister Date: Fri, 3 Sep 2021 15:20:53 +0200 Subject: [PATCH] fix clippy warnings --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index e568a02..fdaa1b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use model::Link; const REDIRECT_TIMEOUT_S: i32 = 2; #[derive(Clone)] -struct CONFIG { +struct Config { root: String, } @@ -58,7 +58,7 @@ async fn edit_page( tmpl: web::Data, query: web::Query>, db_pool: web::Data>, - conf: web::Data, + conf: web::Data, ) -> Result { // one uuid: 9228c1a4-8956-4f1c-8b5f-53cc575bd78 if let Some(uuid_str) = query.get("uuid") { @@ -130,7 +130,7 @@ async fn edit_process( tmpl: web::Data, query: web::Query>, db_pool: web::Data>, - config: web::Data, + config: web::Data, ) -> Result { // TODO: implement handling if let Some(uuid_str) = query.get("uuid") { @@ -139,7 +139,7 @@ async fn edit_process( return error_page(tmpl, "url cannot contain url of ics-proxy".to_string()); }; - if let Err(_) = Url::parse(destination) { + if Url::parse(destination).is_err() { return error_page(tmpl, "could not parse url".to_string()); } @@ -173,7 +173,7 @@ async fn index_process( tmpl: web::Data, query: web::Query>, db_pool: web::Data>, - config: web::Data, + config: web::Data, ) -> Result { if query.get("create").is_some() { let uuid = Uuid::new_v4(); @@ -185,7 +185,7 @@ async fn index_process( return error_page(tmpl, "url cannot contain url of ics-proxy".to_string()); }; - if let Err(_) = Url::parse(destination) { + if Url::parse(destination).is_err() { return error_page(tmpl, "could not parse url".to_string()); } @@ -220,7 +220,7 @@ async fn index_process( match query.get("link") { Some(link) => { // Splitting string and getting uuid, alternatively pretend whole string is uuid - let vec: Vec<&str> = link.split("/").collect(); + let vec: Vec<&str> = link.split('/').collect(); let mut uuid_str = link.to_string(); if vec.len() > 1 { @@ -279,7 +279,7 @@ async fn main() -> std::io::Result<()> { let base_url = std::env::var("BASE_URL").expect("BASE_URL environemt variable error, make sure it is set"); - let conf = CONFIG { + let conf = Config { root: format!("{}://{}", protocol, base_url), };