@@ -2,11 +2,9 @@ use std::{future::Future, time::Instant};
2
2
3
3
use actix_http:: body:: BoxBody ;
4
4
use 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 } ;
8
6
use criterion:: { criterion_group, criterion_main, Criterion } ;
9
- use futures_util:: future:: { join_all, Either } ;
7
+ use futures_util:: future:: join_all;
10
8
11
9
// responder simulate the old responder trait.
12
10
trait FutureResponder {
@@ -16,9 +14,6 @@ trait FutureResponder {
16
14
fn future_respond_to ( self , req : & HttpRequest ) -> Self :: Future ;
17
15
}
18
16
19
- // a simple option responder type.
20
- struct OptionResponder < T > ( Option < T > ) ;
21
-
22
17
// a simple wrapper type around string
23
18
struct StringResponder ( String ) ;
24
19
@@ -34,22 +29,6 @@ impl FutureResponder for StringResponder {
34
29
}
35
30
}
36
31
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
-
53
32
impl Responder for StringResponder {
54
33
type Body = BoxBody ;
55
34
@@ -60,17 +39,6 @@ impl Responder for StringResponder {
60
39
}
61
40
}
62
41
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
-
74
42
fn future_responder ( c : & mut Criterion ) {
75
43
let rt = actix_rt:: System :: new ( ) ;
76
44
let req = TestRequest :: default ( ) . to_http_request ( ) ;
0 commit comments