diff options
| author | Aaron Turon <aturon@mozilla.com> | 2015-03-19 16:37:34 -0700 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2015-03-23 11:27:19 -0700 |
| commit | 9231ceb6dd273d8101e1b3906e6060f802e6423d (patch) | |
| tree | fd81c98f0ae31b117bc16787e1bd68fec9b1a2e1 /src/libcore | |
| parent | 7f53b943f94b338e4c5401f1ce9efbe7da92b0c5 (diff) | |
| download | rust-9231ceb6dd273d8101e1b3906e6060f802e6423d.tar.gz rust-9231ceb6dd273d8101e1b3906e6060f802e6423d.zip | |
Stabilize the Error trait
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change]
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/error.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libcore/error.rs b/src/libcore/error.rs index 161f6c78921..d29964d63a5 100644 --- a/src/libcore/error.rs +++ b/src/libcore/error.rs @@ -82,16 +82,21 @@ #![stable(feature = "rust1", since = "1.0.0")] use prelude::*; -use fmt::Display; +use fmt::{Debug, Display}; /// Base functionality for all errors in Rust. -#[unstable(feature = "core", - reason = "the exact API of this trait may change")] -pub trait Error: Display { - /// A short description of the error; usually a static string. +#[stable(feature = "rust1", since = "1.0.0")] +pub trait Error: Debug + Display + Send { + /// A short description of the error. + /// + /// The description should not contain newlines or sentence-ending + /// punctuation, to facilitate embedding in larger user-facing + /// strings. + #[stable(feature = "rust1", since = "1.0.0")] fn description(&self) -> &str; /// The lower-level cause of this error, if any. + #[stable(feature = "rust1", since = "1.0.0")] fn cause(&self) -> Option<&Error> { None } } |
