mirror of
https://github.com/actix/actix-website
synced 2025-01-22 16:15:56 +01:00
Merge pull request #103 from svenstaro/add-dyn-to-traits
Add dyn keyword to get rid of some warnings
This commit is contained in:
commit
a03b91023c
@ -6,7 +6,7 @@ fn is_error() -> bool {
|
|||||||
use actix_web::{error, Error, HttpResponse};
|
use actix_web::{error, Error, HttpResponse};
|
||||||
use futures::future::{result, Future};
|
use futures::future::{result, Future};
|
||||||
|
|
||||||
fn index() -> Result<Box<Future<Item = HttpResponse, Error = Error>>, Error> {
|
fn index() -> Result<Box<dyn Future<Item = HttpResponse, Error = Error>>, Error> {
|
||||||
if is_error() {
|
if is_error() {
|
||||||
Err(error::ErrorBadRequest("bad request"))
|
Err(error::ErrorBadRequest("bad request"))
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,13 +4,13 @@ pub mod stream;
|
|||||||
use actix_web::{Error, HttpResponse};
|
use actix_web::{Error, HttpResponse};
|
||||||
use futures::future::{ok, Future};
|
use futures::future::{ok, Future};
|
||||||
|
|
||||||
fn index() -> Box<Future<Item = HttpResponse, Error = Error>> {
|
fn index() -> Box<dyn Future<Item = HttpResponse, Error = Error>> {
|
||||||
Box::new(ok::<_, Error>(
|
Box::new(ok::<_, Error>(
|
||||||
HttpResponse::Ok().content_type("text/html").body("Hello!"),
|
HttpResponse::Ok().content_type("text/html").body("Hello!"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn index2() -> Box<Future<Item = &'static str, Error = Error>> {
|
fn index2() -> Box<dyn Future<Item = &'static str, Error = Error>> {
|
||||||
Box::new(ok::<_, Error>("Welcome!"))
|
Box::new(ok::<_, Error>("Welcome!"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ use actix_web::{Either, Error, HttpResponse};
|
|||||||
use futures::future::{ok, Future};
|
use futures::future::{ok, Future};
|
||||||
|
|
||||||
type RegisterResult =
|
type RegisterResult =
|
||||||
Either<HttpResponse, Box<Future<Item = HttpResponse, Error = Error>>>;
|
Either<HttpResponse, Box<dyn Future<Item = HttpResponse, Error = Error>>>;
|
||||||
|
|
||||||
fn index() -> RegisterResult {
|
fn index() -> RegisterResult {
|
||||||
if is_a_variant() {
|
if is_a_variant() {
|
||||||
|
@ -50,7 +50,7 @@ where
|
|||||||
type Request = ServiceRequest;
|
type Request = ServiceRequest;
|
||||||
type Response = ServiceResponse<B>;
|
type Response = ServiceResponse<B>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
|
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>;
|
||||||
|
|
||||||
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
||||||
self.service.poll_ready()
|
self.service.poll_ready()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
use actix_web::{error, web, Error, HttpResponse};
|
use actix_web::{error, web, Error, HttpResponse};
|
||||||
use futures::{future::result, Future, Stream};
|
use futures::{future::result, Future, Stream};
|
||||||
|
|
||||||
pub fn index(payload: web::Payload) -> Box<Future<Item = HttpResponse, Error = Error>> {
|
pub fn index(payload: web::Payload) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {
|
||||||
Box::new(
|
Box::new(
|
||||||
payload
|
payload
|
||||||
.from_err()
|
.from_err()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user