Skip to content

Commit 84b9207

Browse files
committed
---
yaml --- r: 211727 b: refs/heads/auto c: b529a78 h: refs/heads/master i: 211725: d46e229 211723: 1c3ff34 211719: d40736b 211711: 0d2bf2e v: v3
1 parent b0c0f6d commit 84b9207

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 4458b5a9d5f11af5cfeb2201a4065131baeeec36
13+
refs/heads/auto: b529a7837bcbaee4a5e9f61ee659c94af7e41f60
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)