|
34 | 34 | //! particular implementation, but also reveal some of its implementation for
|
35 | 35 | //! debugging via `cause` chains.
|
36 | 36 | //!
|
37 |
| -//! # The `FromError` trait |
38 |
| -//! |
39 |
| -//! `FromError` is a simple trait that expresses conversions between different |
40 |
| -//! error types. To provide maximum flexibility, it does not require either of |
41 |
| -//! the types to actually implement the `Error` trait, although this will be the |
42 |
| -//! common case. |
43 |
| -//! |
44 |
| -//! The main use of this trait is in the `try!` macro, which uses it to |
45 |
| -//! automatically convert a given error to the error specified in a function's |
46 |
| -//! return type. |
47 |
| -//! |
48 | 37 | //! For example,
|
49 | 38 | //!
|
50 | 39 | //! ```
|
|
59 | 48 | //! Map(MapError)
|
60 | 49 | //! }
|
61 | 50 | //!
|
62 |
| -//! impl FromError<IoError> for MyError { |
63 |
| -//! fn from_error(err: IoError) -> MyError { |
| 51 | +//! impl From<IoError> for MyError { |
| 52 | +//! fn from(err: IoError) -> MyError { |
64 | 53 | //! MyError::Io(err)
|
65 | 54 | //! }
|
66 | 55 | //! }
|
67 | 56 | //!
|
68 |
| -//! impl FromError<MapError> for MyError { |
69 |
| -//! fn from_error(err: MapError) -> MyError { |
| 57 | +//! impl From<MapError> for MyError { |
| 58 | +//! fn from(err: MapError) -> MyError { |
70 | 59 | //! MyError::Map(err)
|
71 | 60 | //! }
|
72 | 61 | //! }
|
@@ -100,19 +89,3 @@ pub trait Error: Debug + Display {
|
100 | 89 | #[stable(feature = "rust1", since = "1.0.0")]
|
101 | 90 | fn cause(&self) -> Option<&Error> { None }
|
102 | 91 | }
|
103 |
| - |
104 |
| -/// A trait for types that can be converted from a given error type `E`. |
105 |
| -#[stable(feature = "rust1", since = "1.0.0")] |
106 |
| -pub trait FromError<E> { |
107 |
| - /// Perform the conversion. |
108 |
| - #[stable(feature = "rust1", since = "1.0.0")] |
109 |
| - fn from_error(err: E) -> Self; |
110 |
| -} |
111 |
| - |
112 |
| -// Any type is convertable from itself |
113 |
| -#[stable(feature = "rust1", since = "1.0.0")] |
114 |
| -impl<E> FromError<E> for E { |
115 |
| - fn from_error(err: E) -> E { |
116 |
| - err |
117 |
| - } |
118 |
| -} |
0 commit comments