@@ -7,6 +7,7 @@ use std::mem;
7
7
use std:: path:: Path ;
8
8
use std:: raw:: { self , TraitObject } ;
9
9
use std:: sync:: Arc ;
10
+ use std:: marker:: Reflect ;
10
11
11
12
use openssl:: ssl:: { Ssl , SslStream , SslContext } ;
12
13
use openssl:: ssl:: SslVerifyMode :: SslVerifyNone ;
@@ -117,13 +118,13 @@ impl NetworkStream + Send {
117
118
impl NetworkStream + Send {
118
119
/// Is the underlying type in this trait object a T?
119
120
#[ inline]
120
- pub fn is < T : ' static > ( & self ) -> bool {
121
+ pub fn is < T : Reflect + ' static > ( & self ) -> bool {
121
122
self . get_type_id ( ) == TypeId :: of :: < T > ( )
122
123
}
123
124
124
125
/// If the underlying type is T, get a reference to the contained data.
125
126
#[ inline]
126
- pub fn downcast_ref < T : ' static > ( & self ) -> Option < & T > {
127
+ pub fn downcast_ref < T : Reflect + ' static > ( & self ) -> Option < & T > {
127
128
if self . is :: < T > ( ) {
128
129
Some ( unsafe { self . downcast_ref_unchecked ( ) } )
129
130
} else {
@@ -134,7 +135,7 @@ impl NetworkStream + Send {
134
135
/// If the underlying type is T, get a mutable reference to the contained
135
136
/// data.
136
137
#[ inline]
137
- pub fn downcast_mut < T : ' static > ( & mut self ) -> Option < & mut T > {
138
+ pub fn downcast_mut < T : Reflect + ' static > ( & mut self ) -> Option < & mut T > {
138
139
if self . is :: < T > ( ) {
139
140
Some ( unsafe { self . downcast_mut_unchecked ( ) } )
140
141
} else {
@@ -143,7 +144,7 @@ impl NetworkStream + Send {
143
144
}
144
145
145
146
/// If the underlying type is T, extract it.
146
- pub fn downcast < T : ' static > ( self : Box < NetworkStream + Send > )
147
+ pub fn downcast < T : Reflect + ' static > ( self : Box < NetworkStream + Send > )
147
148
-> Result < Box < T > , Box < NetworkStream + Send > > {
148
149
if self . is :: < T > ( ) {
149
150
Ok ( unsafe { self . downcast_unchecked ( ) } )
0 commit comments