@@ -126,7 +126,7 @@ pub trait Fail: Display + Debug + Send + Sync + 'static {
126
126
/// `Some` when it can return a **different** failure. Users may loop
127
127
/// over the cause chain, and returning `self` would result in an infinite
128
128
/// loop.
129
- fn cause ( & self ) -> Option < & Fail > {
129
+ fn cause ( & self ) -> Option < & dyn Fail > {
130
130
None
131
131
}
132
132
@@ -186,7 +186,7 @@ pub trait Fail: Display + Debug + Send + Sync + 'static {
186
186
since = "0.1.2" ,
187
187
note = "please use the 'find_root_cause()' method instead"
188
188
) ]
189
- fn root_cause ( & self ) -> & Fail
189
+ fn root_cause ( & self ) -> & dyn Fail
190
190
where
191
191
Self : Sized ,
192
192
{
@@ -199,13 +199,13 @@ pub trait Fail: Display + Debug + Send + Sync + 'static {
199
199
}
200
200
}
201
201
202
- impl Fail {
202
+ impl dyn Fail {
203
203
/// Attempts to downcast this failure to a concrete type by reference.
204
204
///
205
205
/// If the underlying error is not of type `T`, this will return `None`.
206
206
pub fn downcast_ref < T : Fail > ( & self ) -> Option < & T > {
207
207
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 ) ) }
209
209
} else {
210
210
None
211
211
}
@@ -217,7 +217,7 @@ impl Fail {
217
217
/// If the underlying error is not of type `T`, this will return `None`.
218
218
pub fn downcast_mut < T : Fail > ( & mut self ) -> Option < & mut T > {
219
219
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 ) ) }
221
221
} else {
222
222
None
223
223
}
@@ -231,7 +231,7 @@ impl Fail {
231
231
///
232
232
/// This is equivalent to iterating over `iter_causes()` and taking
233
233
/// the last item.
234
- pub fn find_root_cause ( & self ) -> & Fail {
234
+ pub fn find_root_cause ( & self ) -> & dyn Fail {
235
235
find_root_cause ( self )
236
236
}
237
237
@@ -258,7 +258,7 @@ impl Fail {
258
258
since = "0.1.2" ,
259
259
note = "please use the 'find_root_cause()' method instead"
260
260
) ]
261
- pub fn root_cause ( & self ) -> & Fail {
261
+ pub fn root_cause ( & self ) -> & dyn Fail {
262
262
find_root_cause ( self )
263
263
}
264
264
@@ -273,8 +273,8 @@ impl Fail {
273
273
impl < E : StdError + Send + Sync + ' static > Fail for E { }
274
274
275
275
#[ 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 > {
278
278
( * * self ) . cause ( )
279
279
}
280
280
@@ -285,20 +285,20 @@ impl Fail for Box<Fail> {
285
285
286
286
/// A iterator over the causes of a `Fail`
287
287
pub struct Causes < ' f > {
288
- fail : Option < & ' f Fail > ,
288
+ fail : Option < & ' f dyn Fail > ,
289
289
}
290
290
291
291
impl < ' 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 > {
294
294
self . fail . map ( |fail| {
295
295
self . fail = fail. cause ( ) ;
296
296
fail
297
297
} )
298
298
}
299
299
}
300
300
301
- fn find_root_cause ( mut fail : & Fail ) -> & Fail {
301
+ fn find_root_cause ( mut fail : & dyn Fail ) -> & dyn Fail {
302
302
while let Some ( cause) = fail. cause ( ) {
303
303
fail = cause;
304
304
}
0 commit comments