1
Fork 0

std: Stabilize last bits of io::Error

This commit stabilizes a few remaining bits of the `io::Error` type:

* The `Error::new` method is now stable. The last `detail` parameter was removed
  and the second `desc` parameter was generalized to `E: Into<Box<Error>>` to
  allow creating an I/O error from any form of error. Currently there is no form
  of downcasting, but this will be added in time.

* An implementation of `From<&str> for Box<Error>` was added to liballoc to
  allow construction of errors from raw strings.

* The `Error::raw_os_error` method was stabilized as-is.

* Trait impls for `Clone`, `Eq`, and `PartialEq` were removed from `Error` as it
  is not possible to use them with trait objects.

This is a breaking change due to the modification of the `new` method as well as
the removal of the trait implementations for the `Error` type.

[breaking-change]
This commit is contained in:
Alex Crichton 2015-03-31 16:01:03 -07:00
parent 80bf31dd51
commit ac77392f8a
23 changed files with 109 additions and 96 deletions

View file

@ -83,7 +83,7 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
if str::from_utf8(&g.s[g.len..]).is_err() {
ret.and_then(|_| {
Err(Error::new(ErrorKind::InvalidInput,
"stream did not contain valid UTF-8", None))
"stream did not contain valid UTF-8"))
})
} else {
g.len = g.s.len();
@ -359,8 +359,7 @@ pub trait Write {
while buf.len() > 0 {
match self.write(buf) {
Ok(0) => return Err(Error::new(ErrorKind::WriteZero,
"failed to write whole buffer",
None)),
"failed to write whole buffer")),
Ok(n) => buf = &buf[n..],
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
Err(e) => return Err(e),
@ -780,7 +779,7 @@ pub struct Chars<R> {
/// An enumeration of possible errors that can be generated from the `Chars`
/// adapter.
#[derive(PartialEq, Clone, Debug)]
#[derive(Debug)]
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
pub enum CharsError {
/// Variant representing that the underlying stream was read successfully