1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-29 13:01:09 +00:00

remove crate level clippy allows

This commit is contained in:
Rob Ede 2021-12-25 04:53:51 +00:00
parent 5860fe5381
commit 2e493cf791
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
10 changed files with 61 additions and 70 deletions

View file

@ -122,9 +122,10 @@ impl<T> App<T> {
self.app_data(Data::new(data)) self.app_data(Data::new(data))
} }
/// Add application data factory. This function is similar to `.data()` but it accepts a /// Add application data factory that resolves asynchronously.
/// "data factory". Data values are constructed asynchronously during application ///
/// initialization, before the server starts accepting requests. /// Data items are constructed during application initialization, before the server starts
/// accepting requests.
pub fn data_factory<F, Out, D, E>(mut self, data: F) -> Self pub fn data_factory<F, Out, D, E>(mut self, data: F) -> Self
where where
F: Fn() -> Out + 'static, F: Fn() -> Out + 'static,
@ -150,6 +151,7 @@ impl<T> App<T> {
} }
.boxed_local() .boxed_local()
})); }));
self self
} }
@ -200,11 +202,9 @@ impl<T> App<T> {
/// "Welcome!" /// "Welcome!"
/// } /// }
/// ///
/// fn main() {
/// let app = App::new() /// let app = App::new()
/// .route("/test1", web::get().to(index)) /// .route("/test1", web::get().to(index))
/// .route("/test2", web::post().to(|| HttpResponse::MethodNotAllowed())); /// .route("/test2", web::post().to(|| HttpResponse::MethodNotAllowed()));
/// }
/// ``` /// ```
pub fn route(self, path: &str, mut route: Route) -> Self { pub fn route(self, path: &str, mut route: Route) -> Self {
self.service( self.service(
@ -243,13 +243,11 @@ impl<T> App<T> {
/// "Welcome!" /// "Welcome!"
/// } /// }
/// ///
/// fn main() {
/// let app = App::new() /// let app = App::new()
/// .service( /// .service(
/// web::resource("/index.html").route(web::get().to(index))) /// web::resource("/index.html").route(web::get().to(index)))
/// .default_service( /// .default_service(
/// web::route().to(|| HttpResponse::NotFound())); /// web::route().to(|| HttpResponse::NotFound()));
/// }
/// ``` /// ```
/// ///
/// It is also possible to use static files as default service. /// It is also possible to use static files as default service.
@ -257,14 +255,12 @@ impl<T> App<T> {
/// ``` /// ```
/// use actix_web::{web, App, HttpResponse}; /// use actix_web::{web, App, HttpResponse};
/// ///
/// fn main() {
/// let app = App::new() /// let app = App::new()
/// .service( /// .service(
/// web::resource("/index.html").to(|| HttpResponse::Ok())) /// web::resource("/index.html").to(|| HttpResponse::Ok()))
/// .default_service( /// .default_service(
/// web::to(|| HttpResponse::NotFound()) /// web::to(|| HttpResponse::NotFound())
/// ); /// );
/// }
/// ``` /// ```
pub fn default_service<F, U>(mut self, svc: F) -> Self pub fn default_service<F, U>(mut self, svc: F) -> Self
where where

View file

@ -236,6 +236,7 @@ where
} }
pub struct AppRoutingFactory { pub struct AppRoutingFactory {
#[allow(clippy::type_complexity)]
services: Rc< services: Rc<
[( [(
ResourceDef, ResourceDef,

View file

@ -24,6 +24,7 @@ pub struct AppService {
config: AppConfig, config: AppConfig,
root: bool, root: bool,
default: Rc<HttpNewService>, default: Rc<HttpNewService>,
#[allow(clippy::type_complexity)]
services: Vec<( services: Vec<(
ResourceDef, ResourceDef,
HttpNewService, HttpNewService,
@ -48,6 +49,7 @@ impl AppService {
self.root self.root
} }
#[allow(clippy::type_complexity)]
pub(crate) fn into_services( pub(crate) fn into_services(
self, self,
) -> ( ) -> (

View file

@ -15,14 +15,12 @@
//! ``` //! ```
//! use actix_web::{web, http, dev, guard, App, HttpResponse}; //! use actix_web::{web, http, dev, guard, App, HttpResponse};
//! //!
//! fn main() {
//! App::new().service(web::resource("/index.html").route( //! App::new().service(web::resource("/index.html").route(
//! web::route() //! web::route()
//! .guard(guard::Post()) //! .guard(guard::Post())
//! .guard(guard::fn_guard(|head| head.method == http::Method::GET)) //! .guard(guard::fn_guard(|head| head.method == http::Method::GET))
//! .to(|| HttpResponse::MethodNotAllowed())) //! .to(|| HttpResponse::MethodNotAllowed()))
//! ); //! );
//! }
//! ``` //! ```
#![allow(non_snake_case)] #![allow(non_snake_case)]
@ -53,7 +51,6 @@ impl Guard for Rc<dyn Guard> {
/// ``` /// ```
/// use actix_web::{guard, web, App, HttpResponse}; /// use actix_web::{guard, web, App, HttpResponse};
/// ///
/// fn main() {
/// App::new().service(web::resource("/index.html").route( /// App::new().service(web::resource("/index.html").route(
/// web::route() /// web::route()
/// .guard( /// .guard(
@ -62,7 +59,6 @@ impl Guard for Rc<dyn Guard> {
/// .contains_key("content-type"))) /// .contains_key("content-type")))
/// .to(|| HttpResponse::MethodNotAllowed())) /// .to(|| HttpResponse::MethodNotAllowed()))
/// ); /// );
/// }
/// ``` /// ```
pub fn fn_guard<F>(f: F) -> impl Guard pub fn fn_guard<F>(f: F) -> impl Guard
where where
@ -96,13 +92,11 @@ where
/// ``` /// ```
/// use actix_web::{web, guard, App, HttpResponse}; /// use actix_web::{web, guard, App, HttpResponse};
/// ///
/// fn main() {
/// App::new().service(web::resource("/index.html").route( /// App::new().service(web::resource("/index.html").route(
/// web::route() /// web::route()
/// .guard(guard::Any(guard::Get()).or(guard::Post())) /// .guard(guard::Any(guard::Get()).or(guard::Post()))
/// .to(|| HttpResponse::MethodNotAllowed())) /// .to(|| HttpResponse::MethodNotAllowed()))
/// ); /// );
/// }
/// ``` /// ```
pub fn Any<F: Guard + 'static>(guard: F) -> AnyGuard { pub fn Any<F: Guard + 'static>(guard: F) -> AnyGuard {
AnyGuard(vec![Box::new(guard)]) AnyGuard(vec![Box::new(guard)])
@ -135,14 +129,12 @@ impl Guard for AnyGuard {
/// ``` /// ```
/// use actix_web::{guard, web, App, HttpResponse}; /// use actix_web::{guard, web, App, HttpResponse};
/// ///
/// fn main() {
/// App::new().service(web::resource("/index.html").route( /// App::new().service(web::resource("/index.html").route(
/// web::route() /// web::route()
/// .guard( /// .guard(
/// guard::All(guard::Get()).and(guard::Header("content-type", "text/plain"))) /// guard::All(guard::Get()).and(guard::Header("content-type", "text/plain")))
/// .to(|| HttpResponse::MethodNotAllowed())) /// .to(|| HttpResponse::MethodNotAllowed()))
/// ); /// );
/// }
/// ``` /// ```
pub fn All<F: Guard + 'static>(guard: F) -> AllGuard { pub fn All<F: Guard + 'static>(guard: F) -> AllGuard {
AllGuard(vec![Box::new(guard)]) AllGuard(vec![Box::new(guard)])

View file

@ -31,8 +31,8 @@ use crate::{
/// The first thing to note is that [`FromRequest`] is implemented for tuples (up to 12 in length). /// The first thing to note is that [`FromRequest`] is implemented for tuples (up to 12 in length).
/// ///
/// Secondly, the `Handler` trait is implemented for functions (up to an [arity] of 12) in a way /// Secondly, the `Handler` trait is implemented for functions (up to an [arity] of 12) in a way
/// that aligns their parameter positions with a corresponding tuple of types (becoming the `T` type /// that aligns their parameter positions with a corresponding tuple of types (becoming the `Args`
/// parameter in this trait's implementation). /// type parameter for this trait).
/// ///
/// Thanks to Rust's type system, Actix Web can infer the function parameter types. During the /// Thanks to Rust's type system, Actix Web can infer the function parameter types. During the
/// extraction step, the parameter types are described as a tuple type, [`from_request`] is run on /// extraction step, the parameter types are described as a tuple type, [`from_request`] is run on
@ -78,12 +78,12 @@ use crate::{
/// [arity]: https://en.wikipedia.org/wiki/Arity /// [arity]: https://en.wikipedia.org/wiki/Arity
/// [`from_request`]: FromRequest::from_request /// [`from_request`]: FromRequest::from_request
/// [on_unimpl]: https://github.com/rust-lang/rust/issues/29628 /// [on_unimpl]: https://github.com/rust-lang/rust/issues/29628
pub trait Handler<T, R>: Clone + 'static pub trait Handler<Args, R>: Clone + 'static
where where
R: Future, R: Future,
R::Output: Responder, R::Output: Responder,
{ {
fn call(&self, args: T) -> R; fn call(&self, args: Args) -> R;
} }
pub(crate) fn handler_service<F, Args, R>(handler: F) -> BoxedHttpServiceFactory pub(crate) fn handler_service<F, Args, R>(handler: F) -> BoxedHttpServiceFactory

View file

@ -66,7 +66,6 @@
#![deny(rust_2018_idioms, nonstandard_style)] #![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)] #![warn(future_incompatible)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]

View file

@ -113,6 +113,7 @@ where
{ {
type Response = ServiceResponse<EitherBody<Encoder<B>>>; type Response = ServiceResponse<EitherBody<Encoder<B>>>;
type Error = Error; type Error = Error;
#[allow(clippy::type_complexity)]
type Future = Either<CompressResponse<S, B>, Ready<Result<Self::Response, Self::Error>>>; type Future = Either<CompressResponse<S, B>, Ready<Result<Self::Response, Self::Error>>>;
actix_service::forward_ready!(service); actix_service::forward_ready!(service);

View file

@ -131,7 +131,6 @@ where
/// ``` /// ```
/// use actix_web::{web, guard, App, HttpResponse}; /// use actix_web::{web, guard, App, HttpResponse};
/// ///
/// fn main() {
/// let app = App::new().service( /// let app = App::new().service(
/// web::resource("/").route( /// web::resource("/").route(
/// web::route() /// web::route()
@ -139,7 +138,6 @@ where
/// .guard(guard::Header("Content-Type", "text/plain")) /// .guard(guard::Header("Content-Type", "text/plain"))
/// .to(|| HttpResponse::Ok())) /// .to(|| HttpResponse::Ok()))
/// ); /// );
/// }
/// ``` /// ```
/// ///
/// Multiple routes could be added to a resource. Resource object uses /// Multiple routes could be added to a resource. Resource object uses

View file

@ -469,6 +469,7 @@ where
} }
pub struct ScopeFactory { pub struct ScopeFactory {
#[allow(clippy::type_complexity)]
services: Rc< services: Rc<
[( [(
ResourceDef, ResourceDef,

View file

@ -63,6 +63,7 @@ where
backlog: u32, backlog: u32,
sockets: Vec<Socket>, sockets: Vec<Socket>,
builder: ServerBuilder, builder: ServerBuilder,
#[allow(clippy::type_complexity)]
on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>, on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>,
_phantom: PhantomData<(S, B)>, _phantom: PhantomData<(S, B)>,
} }