@@ -2,11 +2,9 @@ use std::{future::Future, time::Instant};
22
33use actix_http:: body:: BoxBody ;
44use actix_utils:: future:: { ready, Ready } ;
5- use actix_web:: {
6- error, http:: StatusCode , test:: TestRequest , Error , HttpRequest , HttpResponse , Responder ,
7- } ;
5+ use actix_web:: { http:: StatusCode , test:: TestRequest , Error , HttpRequest , HttpResponse , Responder } ;
86use criterion:: { criterion_group, criterion_main, Criterion } ;
9- use futures_util:: future:: { join_all, Either } ;
7+ use futures_util:: future:: join_all;
108
119// responder simulate the old responder trait.
1210trait FutureResponder {
@@ -16,9 +14,6 @@ trait FutureResponder {
1614 fn future_respond_to ( self , req : & HttpRequest ) -> Self :: Future ;
1715}
1816
19- // a simple option responder type.
20- struct OptionResponder < T > ( Option < T > ) ;
21-
2217// a simple wrapper type around string
2318struct StringResponder ( String ) ;
2419
@@ -34,22 +29,6 @@ impl FutureResponder for StringResponder {
3429 }
3530}
3631
37- impl < T > FutureResponder for OptionResponder < T >
38- where
39- T : FutureResponder ,
40- T :: Future : Future < Output = Result < HttpResponse , Error > > ,
41- {
42- type Error = Error ;
43- type Future = Either < T :: Future , Ready < Result < HttpResponse , Self :: Error > > > ;
44-
45- fn future_respond_to ( self , req : & HttpRequest ) -> Self :: Future {
46- match self . 0 {
47- Some ( t) => Either :: Left ( t. future_respond_to ( req) ) ,
48- None => Either :: Right ( ready ( Err ( error:: ErrorInternalServerError ( "err" ) ) ) ) ,
49- }
50- }
51- }
52-
5332impl Responder for StringResponder {
5433 type Body = BoxBody ;
5534
@@ -60,17 +39,6 @@ impl Responder for StringResponder {
6039 }
6140}
6241
63- impl < T : Responder > Responder for OptionResponder < T > {
64- type Body = BoxBody ;
65-
66- fn respond_to ( self , req : & HttpRequest ) -> HttpResponse < Self :: Body > {
67- match self . 0 {
68- Some ( t) => t. respond_to ( req) . map_into_boxed_body ( ) ,
69- None => HttpResponse :: from_error ( error:: ErrorInternalServerError ( "err" ) ) ,
70- }
71- }
72- }
73-
7442fn future_responder ( c : & mut Criterion ) {
7543 let rt = actix_rt:: System :: new ( ) ;
7644 let req = TestRequest :: default ( ) . to_http_request ( ) ;
0 commit comments