1
0
mirror of https://github.com/actix/examples synced 2025-02-22 17:23:18 +01:00

chore: address clippy warnings

This commit is contained in:
Rob Ede 2025-02-19 22:24:56 +00:00
parent bb18fd8f66
commit 34ab565683
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
5 changed files with 8 additions and 8 deletions

View File

@ -22,7 +22,7 @@ pub struct Human<'a>(&'a StarWarsChar);
/// A humanoid creature in the Star Wars universe. /// A humanoid creature in the Star Wars universe.
#[Object] #[Object]
impl<'a> Human<'a> { impl Human<'_> {
/// The id of the human. /// The id of the human.
async fn id(&self) -> &str { async fn id(&self) -> &str {
self.0.id self.0.id
@ -63,7 +63,7 @@ pub struct Droid<'a>(&'a StarWarsChar);
/// A mechanical creature in the Star Wars universe. /// A mechanical creature in the Star Wars universe.
#[Object] #[Object]
impl<'a> Droid<'a> { impl Droid<'_> {
/// The id of the droid. /// The id of the droid.
async fn id(&self) -> &str { async fn id(&self) -> &str {
self.0.id self.0.id

View File

@ -17,7 +17,7 @@ mod v1 {
ctx.head() ctx.head()
.headers() .headers()
.get("Accept-Version") .get("Accept-Version")
.map_or(false, |hv| hv.as_bytes() == b"1") .is_some_and(|hv| hv.as_bytes() == b"1")
} }
} }
@ -37,7 +37,7 @@ mod v2 {
ctx.head() ctx.head()
.headers() .headers()
.get("Accept-Version") .get("Accept-Version")
.map_or(false, |hv| hv.as_bytes() == b"2") .is_some_and(|hv| hv.as_bytes() == b"2")
} }
} }

View File

@ -52,11 +52,11 @@ async fn main() -> std::io::Result<()> {
Either::Left(srv.call(sreq).map(|res| res)) Either::Left(srv.call(sreq).map(|res| res))
} else { } else {
println!("An http request has arrived here, i will redirect it to use https"); println!("An http request has arrived here, i will redirect it to use https");
return Either::Right(future::ready(Ok(sreq.into_response( Either::Right(future::ready(Ok(sreq.into_response(
HttpResponse::MovedPermanently() HttpResponse::MovedPermanently()
.append_header((http::header::LOCATION, url)) .append_header((http::header::LOCATION, url))
.finish(), .finish(),
)))); ))))
} }
}) })
.service(index) .service(index)

View File

@ -10,7 +10,7 @@ use rand::{rngs::ThreadRng, Rng};
use crate::session; use crate::session;
/// Message for chat server communications /// Message for chat server communications
///
/// New chat session is created /// New chat session is created
#[derive(Message)] #[derive(Message)]
#[rtype(usize)] #[rtype(usize)]

View File

@ -19,7 +19,7 @@ use rand::{rngs::ThreadRng, Rng};
pub struct Message(pub String); pub struct Message(pub String);
/// Message for chat server communications /// Message for chat server communications
///
/// New chat session is created /// New chat session is created
#[derive(Message)] #[derive(Message)]
#[rtype(usize)] #[rtype(usize)]