diff --git a/actix-cors/src/lib.rs b/actix-cors/src/lib.rs index 429fe9eab..579a067b3 100644 --- a/actix-cors/src/lib.rs +++ b/actix-cors/src/lib.rs @@ -160,14 +160,12 @@ impl AllOrSome { /// use actix_cors::Cors; /// use actix_web::http::header; /// -/// # fn main() { /// let cors = Cors::new() /// .allowed_origin("https://www.rust-lang.org/") /// .allowed_methods(vec!["GET", "POST"]) /// .allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT]) /// .allowed_header(header::CONTENT_TYPE) /// .max_age(3600); -/// # } /// ``` #[derive(Default)] pub struct Cors { @@ -585,7 +583,7 @@ impl Inner { AllOrSome::All => Ok(()), AllOrSome::Some(ref allowed_origins) => allowed_origins .get(origin) - .and_then(|_| Some(())) + .map(|_| ()) .ok_or_else(|| CorsError::OriginNotAllowed), }; } @@ -633,7 +631,7 @@ impl Inner { return self .methods .get(&method) - .and_then(|_| Some(())) + .map(|_| ()) .ok_or_else(|| CorsError::MethodNotAllowed); } } @@ -651,6 +649,7 @@ impl Inner { req.headers().get(&header::ACCESS_CONTROL_REQUEST_HEADERS) { if let Ok(headers) = hdr.to_str() { + #[allow(clippy::mutable_key_type)] // FIXME: revisit here let mut hdrs = HashSet::new(); for hdr in headers.split(',') { match HeaderName::try_from(hdr.trim()) { @@ -779,7 +778,7 @@ where { res.headers_mut().insert( header::ACCESS_CONTROL_ALLOW_ORIGIN, - origin.clone(), + origin, ); }; diff --git a/actix-redis/src/session.rs b/actix-redis/src/session.rs index ced1822ad..474d1136d 100644 --- a/actix-redis/src/session.rs +++ b/actix-redis/src/session.rs @@ -134,6 +134,7 @@ where type Request = ServiceRequest; type Response = ServiceResponse; type Error = Error; + #[allow(clippy::type_complexity)] type Future = Pin>>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -266,7 +267,7 @@ impl Inner { value: Option, ) -> Result, Error> { let (value, jar) = if let Some(value) = value { - (value.clone(), None) + (value, None) } else { let value: String = iter::repeat(()) .map(|()| OsRng.sample(Alphanumeric)) @@ -559,7 +560,7 @@ mod test { .unwrap(); assert_eq!( true, - cookie_1.value().to_string() != cookie_2.value().to_string() + cookie_1.value() != cookie_2.value() ); let result_5 = resp_5.json::().await.unwrap(); @@ -618,7 +619,7 @@ mod test { counter: 0 } ); - assert!(cookie_3.value().to_string() != cookie_2.value().to_string()); + assert!(cookie_3.value() != cookie_2.value()); // Step 9: POST to logout, including session cookie #2 // - set-cookie actix-session will be in response with session cookie #2 @@ -632,7 +633,7 @@ mod test { .into_iter() .find(|c| c.name() == "test-session") .unwrap(); - assert!(&time::now().tm_year != &cookie_4.expires().map(|t| t.tm_year).unwrap()); + assert_ne!(time::now().tm_year, cookie_4.expires().map(|t| t.tm_year).unwrap()); // Step 10: GET index, including session cookie #2 in request // - set-cookie actix-session will be in response (session cookie #3) @@ -655,6 +656,6 @@ mod test { .into_iter() .find(|c| c.name() == "test-session") .unwrap(); - assert!(cookie_5.value().to_string() != cookie_2.value().to_string()); + assert!(cookie_5.value() != cookie_2.value()); } }