@@ -38,3 +38,58 @@ pub trait Service<Request> {
38
38
/// The discussion on this is here: <https://github.com/hyperium/hyper/issues/3040>
39
39
fn call ( & self , req : Request ) -> Self :: Future ;
40
40
}
41
+
42
+ impl < Request , S : Service < Request > + ?Sized > Service < Request > for & ' _ S {
43
+ type Response = S :: Response ;
44
+ type Error = S :: Error ;
45
+ type Future = S :: Future ;
46
+
47
+ #[ inline]
48
+ fn call ( & self , req : Request ) -> Self :: Future {
49
+ ( * * self ) . call ( req)
50
+ }
51
+ }
52
+
53
+ impl < Request , S : Service < Request > + ?Sized > Service < Request > for & ' _ mut S {
54
+ type Response = S :: Response ;
55
+ type Error = S :: Error ;
56
+ type Future = S :: Future ;
57
+
58
+ #[ inline]
59
+ fn call ( & self , req : Request ) -> Self :: Future {
60
+ ( * * self ) . call ( req)
61
+ }
62
+ }
63
+
64
+ impl < Request , S : Service < Request > + ?Sized > Service < Request > for Box < S > {
65
+ type Response = S :: Response ;
66
+ type Error = S :: Error ;
67
+ type Future = S :: Future ;
68
+
69
+ #[ inline]
70
+ fn call ( & self , req : Request ) -> Self :: Future {
71
+ ( * * self ) . call ( req)
72
+ }
73
+ }
74
+
75
+ impl < Request , S : Service < Request > + ?Sized > Service < Request > for std:: rc:: Rc < S > {
76
+ type Response = S :: Response ;
77
+ type Error = S :: Error ;
78
+ type Future = S :: Future ;
79
+
80
+ #[ inline]
81
+ fn call ( & self , req : Request ) -> Self :: Future {
82
+ ( * * self ) . call ( req)
83
+ }
84
+ }
85
+
86
+ impl < Request , S : Service < Request > + ?Sized > Service < Request > for std:: sync:: Arc < S > {
87
+ type Response = S :: Response ;
88
+ type Error = S :: Error ;
89
+ type Future = S :: Future ;
90
+
91
+ #[ inline]
92
+ fn call ( & self , req : Request ) -> Self :: Future {
93
+ ( * * self ) . call ( req)
94
+ }
95
+ }
0 commit comments