Skip to content

Commit bb35710

Browse files
committed
---
yaml --- r: 218769 b: refs/heads/snap-stage3 c: b529a78 h: refs/heads/master i: 218767: ae9feb7 v: v3
1 parent e3898ec commit bb35710

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
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: c044791d80ea0dc5c4b57b6030a67b69f8510239
3-
refs/heads/snap-stage3: 4458b5a9d5f11af5cfeb2201a4065131baeeec36
3+
refs/heads/snap-stage3: b529a7837bcbaee4a5e9f61ee659c94af7e41f60
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/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)