@@ -126,7 +126,7 @@ pub trait Fail: Display + Debug + Send + Sync + 'static {
126126 /// `Some` when it can return a **different** failure. Users may loop
127127 /// over the cause chain, and returning `self` would result in an infinite
128128 /// loop.
129- fn cause ( & self ) -> Option < & Fail > {
129+ fn cause ( & self ) -> Option < & dyn Fail > {
130130 None
131131 }
132132
@@ -186,7 +186,7 @@ pub trait Fail: Display + Debug + Send + Sync + 'static {
186186 since = "0.1.2" ,
187187 note = "please use the 'find_root_cause()' method instead"
188188 ) ]
189- fn root_cause ( & self ) -> & Fail
189+ fn root_cause ( & self ) -> & dyn Fail
190190 where
191191 Self : Sized ,
192192 {
@@ -199,13 +199,13 @@ pub trait Fail: Display + Debug + Send + Sync + 'static {
199199 }
200200}
201201
202- impl Fail {
202+ impl dyn Fail {
203203 /// Attempts to downcast this failure to a concrete type by reference.
204204 ///
205205 /// If the underlying error is not of type `T`, this will return `None`.
206206 pub fn downcast_ref < T : Fail > ( & self ) -> Option < & T > {
207207 if self . __private_get_type_id__ ( ) == TypeId :: of :: < T > ( ) {
208- unsafe { Some ( & * ( self as * const Fail as * const T ) ) }
208+ unsafe { Some ( & * ( self as * const dyn Fail as * const T ) ) }
209209 } else {
210210 None
211211 }
@@ -217,7 +217,7 @@ impl Fail {
217217 /// If the underlying error is not of type `T`, this will return `None`.
218218 pub fn downcast_mut < T : Fail > ( & mut self ) -> Option < & mut T > {
219219 if self . __private_get_type_id__ ( ) == TypeId :: of :: < T > ( ) {
220- unsafe { Some ( & mut * ( self as * mut Fail as * mut T ) ) }
220+ unsafe { Some ( & mut * ( self as * mut dyn Fail as * mut T ) ) }
221221 } else {
222222 None
223223 }
@@ -231,7 +231,7 @@ impl Fail {
231231 ///
232232 /// This is equivalent to iterating over `iter_causes()` and taking
233233 /// the last item.
234- pub fn find_root_cause ( & self ) -> & Fail {
234+ pub fn find_root_cause ( & self ) -> & dyn Fail {
235235 find_root_cause ( self )
236236 }
237237
@@ -258,7 +258,7 @@ impl Fail {
258258 since = "0.1.2" ,
259259 note = "please use the 'find_root_cause()' method instead"
260260 ) ]
261- pub fn root_cause ( & self ) -> & Fail {
261+ pub fn root_cause ( & self ) -> & dyn Fail {
262262 find_root_cause ( self )
263263 }
264264
@@ -273,8 +273,8 @@ impl Fail {
273273impl < E : StdError + Send + Sync + ' static > Fail for E { }
274274
275275#[ cfg( feature = "std" ) ]
276- impl Fail for Box < Fail > {
277- fn cause ( & self ) -> Option < & Fail > {
276+ impl Fail for Box < dyn Fail > {
277+ fn cause ( & self ) -> Option < & dyn Fail > {
278278 ( * * self ) . cause ( )
279279 }
280280
@@ -285,20 +285,20 @@ impl Fail for Box<Fail> {
285285
286286/// A iterator over the causes of a `Fail`
287287pub struct Causes < ' f > {
288- fail : Option < & ' f Fail > ,
288+ fail : Option < & ' f dyn Fail > ,
289289}
290290
291291impl < ' f > Iterator for Causes < ' f > {
292- type Item = & ' f Fail ;
293- fn next ( & mut self ) -> Option < & ' f Fail > {
292+ type Item = & ' f dyn Fail ;
293+ fn next ( & mut self ) -> Option < & ' f dyn Fail > {
294294 self . fail . map ( |fail| {
295295 self . fail = fail. cause ( ) ;
296296 fail
297297 } )
298298 }
299299}
300300
301- fn find_root_cause ( mut fail : & Fail ) -> & Fail {
301+ fn find_root_cause ( mut fail : & dyn Fail ) -> & dyn Fail {
302302 while let Some ( cause) = fail. cause ( ) {
303303 fail = cause;
304304 }
0 commit comments