no need for generics

This commit is contained in:
Nikolay Kim 2020-04-12 00:54:44 +06:00
parent cd79c0e997
commit 2299b75a74
3 changed files with 11 additions and 16 deletions

View file

@ -186,7 +186,7 @@ pub trait ServiceFactory {
/// Errors produced while building a service. /// Errors produced while building a service.
type InitError; type InitError;
/// The future of the `Service` instance. /// The future of the `ServiceFactory` instance.
type Future: Future<Output = Result<Self::Service, Self::InitError>>; type Future: Future<Output = Result<Self::Service, Self::InitError>>;
/// Create and return a new service value asynchronously. /// Create and return a new service value asynchronously.

View file

@ -30,9 +30,8 @@ use crate::web::dev::{WebRequest, WebResponse};
/// } /// }
/// ``` /// ```
#[derive(Clone)] #[derive(Clone)]
pub struct DefaultHeaders<E> { pub struct DefaultHeaders {
inner: Rc<Inner>, inner: Rc<Inner>,
_t: PhantomData<E>,
} }
struct Inner { struct Inner {
@ -40,21 +39,20 @@ struct Inner {
headers: HeaderMap, headers: HeaderMap,
} }
impl<E> Default for DefaultHeaders<E> { impl Default for DefaultHeaders {
fn default() -> Self { fn default() -> Self {
DefaultHeaders { DefaultHeaders {
inner: Rc::new(Inner { inner: Rc::new(Inner {
ct: false, ct: false,
headers: HeaderMap::new(), headers: HeaderMap::new(),
}), }),
_t: PhantomData,
} }
} }
} }
impl<E> DefaultHeaders<E> { impl DefaultHeaders {
/// Construct `DefaultHeaders` middleware. /// Construct `DefaultHeaders` middleware.
pub fn new() -> DefaultHeaders<E> { pub fn new() -> DefaultHeaders {
DefaultHeaders::default() DefaultHeaders::default()
} }
@ -92,7 +90,7 @@ impl<E> DefaultHeaders<E> {
} }
} }
impl<S, E> Transform<S> for DefaultHeaders<E> impl<S, E> Transform<S> for DefaultHeaders
where where
S: Service<Request = WebRequest<E>, Response = WebResponse>, S: Service<Request = WebRequest<E>, Response = WebResponse>,
S::Future: 'static, S::Future: 'static,

View file

@ -77,9 +77,8 @@ use crate::web::HttpResponse;
/// ///
/// `%{FOO}e` os.environ['FOO'] /// `%{FOO}e` os.environ['FOO']
/// ///
pub struct Logger<Err> { pub struct Logger {
inner: Rc<Inner>, inner: Rc<Inner>,
_t: PhantomData<Err>,
} }
struct Inner { struct Inner {
@ -87,15 +86,14 @@ struct Inner {
exclude: HashSet<String>, exclude: HashSet<String>,
} }
impl<Err> Logger<Err> { impl Logger {
/// Create `Logger` middleware with the specified `format`. /// Create `Logger` middleware with the specified `format`.
pub fn new(format: &str) -> Logger<Err> { pub fn new(format: &str) -> Logger {
Logger { Logger {
inner: Rc::new(Inner { inner: Rc::new(Inner {
format: Format::new(format), format: Format::new(format),
exclude: HashSet::new(), exclude: HashSet::new(),
}), }),
_t: PhantomData,
} }
} }
@ -109,7 +107,7 @@ impl<Err> Logger<Err> {
} }
} }
impl<Err> Default for Logger<Err> { impl Default for Logger {
/// Create `Logger` middleware with format: /// Create `Logger` middleware with format:
/// ///
/// ```ignore /// ```ignore
@ -121,12 +119,11 @@ impl<Err> Default for Logger<Err> {
format: Format::default(), format: Format::default(),
exclude: HashSet::new(), exclude: HashSet::new(),
}), }),
_t: PhantomData,
} }
} }
} }
impl<S, Err> Transform<S> for Logger<Err> impl<S, Err> Transform<S> for Logger
where where
S: Service<Request = WebRequest<Err>, Response = WebResponse>, S: Service<Request = WebRequest<Err>, Response = WebResponse>,
{ {