1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 22:49:21 +02:00

nightly clippy warnings

This commit is contained in:
Nikolay Kim
2019-07-17 15:48:37 +06:00
parent 4092c7f326
commit 2a2d7f5768
34 changed files with 104 additions and 99 deletions

View File

@ -23,16 +23,17 @@ use crate::service::{
};
type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error, ()>;
type FnDataFactory = Box<Fn() -> Box<dyn Future<Item = Box<DataFactory>, Error = ()>>>;
type FnDataFactory =
Box<dyn Fn() -> Box<dyn Future<Item = Box<dyn DataFactory>, Error = ()>>>;
/// Application builder - structure that follows the builder pattern
/// for building application instances.
pub struct App<T, B> {
endpoint: T,
services: Vec<Box<ServiceFactory>>,
services: Vec<Box<dyn ServiceFactory>>,
default: Option<Rc<HttpNewService>>,
factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
data: Vec<Box<DataFactory>>,
data: Vec<Box<dyn DataFactory>>,
data_factories: Vec<FnDataFactory>,
config: AppConfigInner,
external: Vec<ResourceDef>,

View File

@ -18,14 +18,15 @@ use crate::request::{HttpRequest, HttpRequestPool};
use crate::rmap::ResourceMap;
use crate::service::{ServiceFactory, ServiceRequest, ServiceResponse};
type Guards = Vec<Box<Guard>>;
type Guards = Vec<Box<dyn Guard>>;
type HttpService = BoxedService<ServiceRequest, ServiceResponse, Error>;
type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error, ()>;
type BoxedResponse = Either<
FutureResult<ServiceResponse, Error>,
Box<dyn Future<Item = ServiceResponse, Error = Error>>,
>;
type FnDataFactory = Box<Fn() -> Box<dyn Future<Item = Box<DataFactory>, Error = ()>>>;
type FnDataFactory =
Box<dyn Fn() -> Box<dyn Future<Item = Box<dyn DataFactory>, Error = ()>>>;
/// Service factory to convert `Request` to a `ServiceRequest<S>`.
/// It also executes data factories.
@ -40,10 +41,10 @@ where
>,
{
pub(crate) endpoint: T,
pub(crate) data: Rc<Vec<Box<DataFactory>>>,
pub(crate) data: Rc<Vec<Box<dyn DataFactory>>>,
pub(crate) data_factories: Rc<Vec<FnDataFactory>>,
pub(crate) config: RefCell<AppConfig>,
pub(crate) services: Rc<RefCell<Vec<Box<ServiceFactory>>>>,
pub(crate) services: Rc<RefCell<Vec<Box<dyn ServiceFactory>>>>,
pub(crate) default: Option<Rc<HttpNewService>>,
pub(crate) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
pub(crate) external: RefCell<Vec<ResourceDef>>,
@ -142,9 +143,9 @@ where
endpoint_fut: T::Future,
rmap: Rc<ResourceMap>,
config: AppConfig,
data: Rc<Vec<Box<DataFactory>>>,
data_factories: Vec<Box<DataFactory>>,
data_factories_fut: Vec<Box<dyn Future<Item = Box<DataFactory>, Error = ()>>>,
data: Rc<Vec<Box<dyn DataFactory>>>,
data_factories: Vec<Box<dyn DataFactory>>,
data_factories_fut: Vec<Box<dyn Future<Item = Box<dyn DataFactory>, Error = ()>>>,
_t: PhantomData<B>,
}

View File

@ -16,7 +16,7 @@ use crate::service::{
ServiceResponse,
};
type Guards = Vec<Box<Guard>>;
type Guards = Vec<Box<dyn Guard>>;
type HttpNewService =
boxed::BoxedNewService<(), ServiceRequest, ServiceResponse, Error, ()>;
@ -31,7 +31,7 @@ pub struct AppService {
Option<Guards>,
Option<Rc<ResourceMap>>,
)>,
service_data: Rc<Vec<Box<DataFactory>>>,
service_data: Rc<Vec<Box<dyn DataFactory>>>,
}
impl AppService {
@ -39,7 +39,7 @@ impl AppService {
pub(crate) fn new(
config: AppConfig,
default: Rc<HttpNewService>,
service_data: Rc<Vec<Box<DataFactory>>>,
service_data: Rc<Vec<Box<dyn DataFactory>>>,
) -> Self {
AppService {
config,
@ -101,7 +101,7 @@ impl AppService {
pub fn register_service<F, S>(
&mut self,
rdef: ResourceDef,
guards: Option<Vec<Box<Guard>>>,
guards: Option<Vec<Box<dyn Guard>>>,
service: F,
nested: Option<Rc<ResourceMap>>,
) where
@ -174,8 +174,8 @@ impl Default for AppConfigInner {
/// to set of external methods. This could help with
/// modularization of big application configuration.
pub struct ServiceConfig {
pub(crate) services: Vec<Box<ServiceFactory>>,
pub(crate) data: Vec<Box<DataFactory>>,
pub(crate) services: Vec<Box<dyn ServiceFactory>>,
pub(crate) data: Vec<Box<dyn DataFactory>>,
pub(crate) external: Vec<ResourceDef>,
}

View File

@ -100,7 +100,7 @@ pub fn Any<F: Guard + 'static>(guard: F) -> AnyGuard {
}
/// Matches if any of supplied guards matche.
pub struct AnyGuard(Vec<Box<Guard>>);
pub struct AnyGuard(Vec<Box<dyn Guard>>);
impl AnyGuard {
/// Add guard to a list of guards to check
@ -140,7 +140,7 @@ pub fn All<F: Guard + 'static>(guard: F) -> AllGuard {
}
/// Matches if all of supplied guards.
pub struct AllGuard(Vec<Box<Guard>>);
pub struct AllGuard(Vec<Box<dyn Guard>>);
impl AllGuard {
/// Add new guard to the list of guards to check
@ -167,7 +167,7 @@ pub fn Not<F: Guard + 'static>(guard: F) -> NotGuard {
}
#[doc(hidden)]
pub struct NotGuard(Box<Guard>);
pub struct NotGuard(Box<dyn Guard>);
impl Guard for NotGuard {
fn check(&self, request: &RequestHead) -> bool {

View File

@ -18,7 +18,7 @@ pub enum ErrorHandlerResponse<B> {
Future(Box<dyn Future<Item = ServiceResponse<B>, Error = Error>>),
}
type ErrorHandler<B> = Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>>;
type ErrorHandler<B> = dyn Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>>;
/// `Middleware` for allowing custom handlers for responses.
///

View File

@ -444,7 +444,9 @@ impl FormatText {
}
}
pub(crate) struct FormatDisplay<'a>(&'a Fn(&mut Formatter) -> Result<(), fmt::Error>);
pub(crate) struct FormatDisplay<'a>(
&'a dyn Fn(&mut Formatter) -> Result<(), fmt::Error>,
);
impl<'a> fmt::Display for FormatDisplay<'a> {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {

View File

@ -50,7 +50,7 @@ pub struct Resource<T = ResourceEndpoint> {
name: Option<String>,
routes: Vec<Route>,
data: Option<Extensions>,
guards: Vec<Box<Guard>>,
guards: Vec<Box<dyn Guard>>,
default: Rc<RefCell<Option<Rc<HttpNewService>>>>,
factory_ref: Rc<RefCell<Option<ResourceFactory>>>,
}
@ -118,7 +118,7 @@ where
self
}
pub(crate) fn add_guards(mut self, guards: Vec<Box<Guard>>) -> Self {
pub(crate) fn add_guards(mut self, guards: Vec<Box<dyn Guard>>) -> Self {
self.guards.extend(guards);
self
}

View File

@ -13,7 +13,7 @@ use crate::service::{ServiceRequest, ServiceResponse};
use crate::HttpResponse;
type BoxedRouteService<Req, Res> = Box<
Service<
dyn Service<
Request = Req,
Response = Res,
Error = Error,
@ -25,7 +25,7 @@ type BoxedRouteService<Req, Res> = Box<
>;
type BoxedRouteNewService<Req, Res> = Box<
NewService<
dyn NewService<
Config = (),
Request = Req,
Response = Res,
@ -42,7 +42,7 @@ type BoxedRouteNewService<Req, Res> = Box<
/// If handler is not explicitly set, default *404 Not Found* handler is used.
pub struct Route {
service: BoxedRouteNewService<ServiceRequest, ServiceResponse>,
guards: Rc<Vec<Box<Guard>>>,
guards: Rc<Vec<Box<dyn Guard>>>,
}
impl Route {
@ -56,7 +56,7 @@ impl Route {
}
}
pub(crate) fn take_guards(&mut self) -> Vec<Box<Guard>> {
pub(crate) fn take_guards(&mut self) -> Vec<Box<dyn Guard>> {
std::mem::replace(Rc::get_mut(&mut self.guards).unwrap(), Vec::new())
}
}
@ -84,7 +84,7 @@ type RouteFuture = Box<
pub struct CreateRouteService {
fut: RouteFuture,
guards: Rc<Vec<Box<Guard>>>,
guards: Rc<Vec<Box<dyn Guard>>>,
}
impl Future for CreateRouteService {
@ -104,7 +104,7 @@ impl Future for CreateRouteService {
pub struct RouteService {
service: BoxedRouteService<ServiceRequest, ServiceResponse>,
guards: Rc<Vec<Box<Guard>>>,
guards: Rc<Vec<Box<dyn Guard>>>,
}
impl RouteService {

View File

@ -23,7 +23,7 @@ use crate::service::{
ServiceFactory, ServiceFactoryWrapper, ServiceRequest, ServiceResponse,
};
type Guards = Vec<Box<Guard>>;
type Guards = Vec<Box<dyn Guard>>;
type HttpService = BoxedService<ServiceRequest, ServiceResponse, Error>;
type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error, ()>;
type BoxedResponse = Either<
@ -64,8 +64,8 @@ pub struct Scope<T = ScopeEndpoint> {
endpoint: T,
rdef: String,
data: Option<Extensions>,
services: Vec<Box<ServiceFactory>>,
guards: Vec<Box<Guard>>,
services: Vec<Box<dyn ServiceFactory>>,
guards: Vec<Box<dyn Guard>>,
default: Rc<RefCell<Option<Rc<HttpNewService>>>>,
external: Vec<ResourceDef>,
factory_ref: Rc<RefCell<Option<ScopeFactory>>>,
@ -578,7 +578,7 @@ impl Future for ScopeFactoryResponse {
pub struct ScopeService {
data: Option<Rc<Extensions>>,
router: Router<HttpService, Vec<Box<Guard>>>,
router: Router<HttpService, Vec<Box<dyn Guard>>>,
default: Option<HttpService>,
_ready: Option<(ServiceRequest, ResourceInfo)>,
}

View File

@ -407,7 +407,7 @@ impl<B: MessageBody> fmt::Debug for ServiceResponse<B> {
pub struct WebService {
rdef: String,
name: Option<String>,
guards: Vec<Box<Guard>>,
guards: Vec<Box<dyn Guard>>,
}
impl WebService {
@ -476,7 +476,7 @@ struct WebServiceImpl<T> {
srv: T,
rdef: String,
name: Option<String>,
guards: Vec<Box<Guard>>,
guards: Vec<Box<dyn Guard>>,
}
impl<T> HttpServiceFactory for WebServiceImpl<T>

View File

@ -141,7 +141,7 @@ impl<T: fmt::Display> fmt::Display for Form<T> {
#[derive(Clone)]
pub struct FormConfig {
limit: usize,
ehandler: Option<Rc<Fn(UrlencodedError, &HttpRequest) -> Error>>,
ehandler: Option<Rc<dyn Fn(UrlencodedError, &HttpRequest) -> Error>>,
}
impl FormConfig {

View File

@ -224,7 +224,7 @@ where
/// ```
#[derive(Clone)]
pub struct PathConfig {
ehandler: Option<Arc<Fn(PathError, &HttpRequest) -> Error + Send + Sync>>,
ehandler: Option<Arc<dyn Fn(PathError, &HttpRequest) -> Error + Send + Sync>>,
}
impl PathConfig {

View File

@ -128,7 +128,7 @@ impl FromRequest for Bytes {
#[inline]
fn from_request(req: &HttpRequest, payload: &mut dev::Payload) -> Self::Future {
let mut tmp;
let tmp;
let cfg = if let Some(cfg) = req.app_data::<PayloadConfig>() {
cfg
} else {
@ -184,7 +184,7 @@ impl FromRequest for String {
#[inline]
fn from_request(req: &HttpRequest, payload: &mut dev::Payload) -> Self::Future {
let mut tmp;
let tmp;
let cfg = if let Some(cfg) = req.app_data::<PayloadConfig>() {
cfg
} else {

View File

@ -192,7 +192,8 @@ where
/// ```
#[derive(Clone)]
pub struct QueryConfig {
ehandler: Option<Arc<Fn(QueryPayloadError, &HttpRequest) -> Error + Send + Sync>>,
ehandler:
Option<Arc<dyn Fn(QueryPayloadError, &HttpRequest) -> Error + Send + Sync>>,
}
impl QueryConfig {