Skip to content

Commit 065f7a2

Browse files
committed
---
yaml --- r: 212025 b: refs/heads/tmp c: b529a78 h: refs/heads/master i: 212023: 88aba40 v: v3
1 parent 8433f03 commit 065f7a2

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 62e70d35be3fe532c26a400b499c58a18f18dd3a
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 4458b5a9d5f11af5cfeb2201a4065131baeeec36
35+
refs/heads/tmp: b529a7837bcbaee4a5e9f61ee659c94af7e41f60
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: b77d60adb019bb5de05e884a99f3290ec4694137
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/libstd/io/error.rs

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ impl Error {
129129
///
130130
/// This function is used to generically create I/O errors which do not
131131
/// originate from the OS itself. The `error` argument is an arbitrary
132-
/// payload which will be contained in this `Error`. Accessors as well as
133-
/// downcasting will soon be added to this type as well to access the custom
134-
/// information.
132+
/// payload which will be contained in this `Error`.
135133
///
136134
/// # Examples
137135
///
@@ -174,8 +172,9 @@ impl Error {
174172

175173
/// Returns the OS error that this error represents (if any).
176174
///
177-
/// If this `Error` was constructed via `last_os_error` then this function
178-
/// will return `Some`, otherwise it will return `None`.
175+
/// If this `Error` was constructed via `last_os_error` or
176+
/// `from_raw_os_error`, then this function will return `Some`, otherwise
177+
/// it will return `None`.
179178
#[stable(feature = "rust1", since = "1.0.0")]
180179
pub fn raw_os_error(&self) -> Option<i32> {
181180
match self.repr {
@@ -184,6 +183,43 @@ impl Error {
184183
}
185184
}
186185

186+
/// Returns a reference to the inner error wrapped by this error (if any).
187+
///
188+
/// If this `Error` was constructed via `new` then this function will
189+
/// return `Some`, otherwise it will return `None`.
190+
#[unstable(feature = "io_error_inner", reason = "recently added")]
191+
pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync)> {
192+
match self.repr {
193+
Repr::Os(..) => None,
194+
Repr::Custom(ref c) => Some(&*c.error),
195+
}
196+
}
197+
198+
/// Returns a mutable reference to the inner error wrapped by this error
199+
/// (if any).
200+
///
201+
/// If this `Error` was constructed via `new` then this function will
202+
/// return `Some`, otherwise it will return `None`.
203+
#[unstable(feature = "io_error_inner", reason = "recently added")]
204+
pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync)> {
205+
match self.repr {
206+
Repr::Os(..) => None,
207+
Repr::Custom(ref mut c) => Some(&mut *c.error),
208+
}
209+
}
210+
211+
/// Consumes the `Error`, returning its inner error (if any).
212+
///
213+
/// If this `Error` was constructed via `new` then this function will
214+
/// return `Some`, otherwise it will return `None`.
215+
#[unstable(feature = "io_error_inner", reason = "recently added")]
216+
pub fn into_inner(self) -> Option<Box<error::Error+Send+Sync>> {
217+
match self.repr {
218+
Repr::Os(..) => None,
219+
Repr::Custom(c) => Some(c.error)
220+
}
221+
}
222+
187223
/// Returns the corresponding `ErrorKind` for this error.
188224
#[stable(feature = "rust1", since = "1.0.0")]
189225
pub fn kind(&self) -> ErrorKind {
@@ -216,7 +252,7 @@ impl error::Error for Error {
216252
}
217253
}
218254

219-
fn cause(&self) -> Option<&Error> {
255+
fn cause(&self) -> Option<&error::Error> {
220256
match self.repr {
221257
Repr::Os(..) => None,
222258
Repr::Custom(ref c) => c.error.cause(),

0 commit comments

Comments
 (0)