Skip to content

Commit 7de9a73

Browse files
committed
Stabilize std::error
This commit is a first past stabilization of `std::error`: * The module is stable. * The `FromError` trait and impls are stable * The `Error` trait itself is left unstable, pending current APIs and possible revisions during the alpha cycle.
1 parent 8efd990 commit 7de9a73

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libstd/error.rs

+8
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@
7878
//! }
7979
//! ```
8080
81+
#![stable]
82+
8183
use prelude::v1::*;
8284

8385
use str::Utf8Error;
8486
use string::{FromUtf8Error, FromUtf16Error};
8587

8688
/// Base functionality for all errors in Rust.
89+
#[unstable = "the exact API of this trait may change"]
8790
pub trait Error: Send {
8891
/// A short description of the error; usually a static string.
8992
fn description(&self) -> &str;
@@ -96,18 +99,21 @@ pub trait Error: Send {
9699
}
97100

98101
/// A trait for types that can be converted from a given error type `E`.
102+
#[stable]
99103
pub trait FromError<E> {
100104
/// Perform the conversion.
101105
fn from_error(err: E) -> Self;
102106
}
103107

104108
// Any type is convertable from itself
109+
#[stable]
105110
impl<E> FromError<E> for E {
106111
fn from_error(err: E) -> E {
107112
err
108113
}
109114
}
110115

116+
#[stable]
111117
impl Error for Utf8Error {
112118
fn description(&self) -> &str {
113119
match *self {
@@ -119,11 +125,13 @@ impl Error for Utf8Error {
119125
fn detail(&self) -> Option<String> { Some(self.to_string()) }
120126
}
121127

128+
#[stable]
122129
impl Error for FromUtf8Error {
123130
fn description(&self) -> &str { "invalid utf-8" }
124131
fn detail(&self) -> Option<String> { Some(self.to_string()) }
125132
}
126133

134+
#[stable]
127135
impl Error for FromUtf16Error {
128136
fn description(&self) -> &str { "invalid utf-16" }
129137
}

0 commit comments

Comments
 (0)