From 6056e6d92abcbaa528ee6e719c2aa29e4420ff31 Mon Sep 17 00:00:00 2001 From: Antoine Romero-Romero Date: Fri, 15 Jul 2022 23:24:31 +0100 Subject: [PATCH] fix: clippy warnings --- src/executors/mod.rs | 2 +- src/request_handler/mod.rs | 2 +- src/routers/const_router.rs | 7 ++++--- src/server.rs | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/executors/mod.rs b/src/executors/mod.rs index 513f7fcd8..22430eca5 100644 --- a/src/executors/mod.rs +++ b/src/executors/mod.rs @@ -129,7 +129,7 @@ pub async fn execute_function( number_of_params: u8, is_async: bool, ) -> Result> { - let mut request: HashMap = HashMap::new(); + let request: HashMap = HashMap::new(); if is_async { let output = Python::with_gil(|py| { diff --git a/src/request_handler/mod.rs b/src/request_handler/mod.rs index 471ee4707..5e1d93314 100644 --- a/src/request_handler/mod.rs +++ b/src/request_handler/mod.rs @@ -72,7 +72,7 @@ pub async fn handle_http_request( debug!("These are the headers from serde {:?}", headers); let mut response = HttpResponse::build(status_code); - apply_headers(&mut response, headers.clone()); + apply_headers(&mut response, headers); let final_response = if !body.is_empty() { response.body(body) } else { diff --git a/src/routers/const_router.rs b/src/routers/const_router.rs index f240bbc48..675324424 100644 --- a/src/routers/const_router.rs +++ b/src/routers/const_router.rs @@ -1,7 +1,7 @@ +use std::sync::Arc; use std::sync::RwLock; -use std::{collections::HashMap, sync::Arc}; // pyo3 modules -use crate::{executors::execute_function, types::PyFunction}; +use crate::executors::execute_function; use log::debug; use pyo3::prelude::*; use pyo3::types::PyAny; @@ -115,8 +115,9 @@ impl ConstRouter { ) -> Option { // need to split this function in multiple smaller functions let table = self.get_relevant_map(route_method)?; + let route_map = table.read().ok()?; - match table.clone().read().unwrap().at(route) { + match route_map.at(route) { Ok(res) => Some(res.value.clone()), Err(_) => None, } diff --git a/src/server.rs b/src/server.rs index a3d40a3f0..3bd5249a8 100644 --- a/src/server.rs +++ b/src/server.rs @@ -253,6 +253,7 @@ impl Server { /// Add a new route to the routing tables /// can be called after the server has been started + #[allow(clippy::too_many_arguments)] pub fn add_route( &self, py: Python, @@ -425,7 +426,7 @@ async fn index( } }; - let _ = match middleware_router.get_route("AFTER_REQUEST", req.uri().path()) { + match middleware_router.get_route("AFTER_REQUEST", req.uri().path()) { Some(((handler_function, number_of_params), route_params)) => { let x = handle_http_middleware_request( handler_function,