Skip to content

Commit b784bbb

Browse files
committed
---
yaml --- r: 209173 b: refs/heads/master c: b529a78 h: refs/heads/master i: 209171: 2450fd0 v: v3
1 parent 9e810ac commit b784bbb

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,5 +1,5 @@
11
---
2-
refs/heads/master: 4458b5a9d5f11af5cfeb2201a4065131baeeec36
2+
refs/heads/master: b529a7837bcbaee4a5e9f61ee659c94af7e41f60
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f

trunk/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)