diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-08-04 01:59:24 +0200 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-08-05 22:42:21 +0200 |
| commit | 0ac7a219f043d3b1c8c239089d9dd6e6c9fa830b (patch) | |
| tree | 6dbb028659dbc0931ec23398e529549c84bba0a4 /src/libstd/rt/io | |
| parent | d8b299d179653cbde783f62f70b5531dbaa5c5a6 (diff) | |
Updated std::Option, std::Either and std::Result
- Made naming schemes consistent between Option, Result and Either - Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None) - Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
Diffstat (limited to 'src/libstd/rt/io')
| -rw-r--r-- | src/libstd/rt/io/flate.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/io/mod.rs | 36 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/libstd/rt/io/flate.rs b/src/libstd/rt/io/flate.rs index e57b80658ee..bea62f7e28c 100644 --- a/src/libstd/rt/io/flate.rs +++ b/src/libstd/rt/io/flate.rs @@ -115,7 +115,7 @@ mod test { let mem_reader = MemReader::new(buf); let mut inflate_reader = InflateReader::new(mem_reader); let mut out_bytes = [0, .. 100]; - let bytes_read = inflate_reader.read(out_bytes).get(); + let bytes_read = inflate_reader.read(out_bytes).unwrap(); assert_eq!(bytes_read, in_bytes.len()); let out_msg = str::from_bytes(out_bytes); assert!(in_msg == out_msg); diff --git a/src/libstd/rt/io/mod.rs b/src/libstd/rt/io/mod.rs index 838c2d86c9f..c980dc9d73e 100644 --- a/src/libstd/rt/io/mod.rs +++ b/src/libstd/rt/io/mod.rs @@ -243,6 +243,8 @@ Out of scope */ use prelude::*; +use to_str::ToStr; +use str::{StrSlice, OwnedStr}; // Reexports pub use self::stdio::stdin; @@ -334,6 +336,20 @@ pub struct IoError { detail: Option<~str> } +// FIXME: #8242 implementing manually because deriving doesn't work for some reason +impl ToStr for IoError { + fn to_str(&self) -> ~str { + let mut s = ~"IoError { kind: "; + s.push_str(self.kind.to_str()); + s.push_str(", desc: "); + s.push_str(self.desc); + s.push_str(", detail: "); + s.push_str(self.detail.to_str()); + s.push_str(" }"); + s + } +} + #[deriving(Eq)] pub enum IoErrorKind { PreviousIoError, @@ -348,6 +364,24 @@ pub enum IoErrorKind { BrokenPipe } +// FIXME: #8242 implementing manually because deriving doesn't work for some reason +impl ToStr for IoErrorKind { + fn to_str(&self) -> ~str { + match *self { + PreviousIoError => ~"PreviousIoError", + OtherIoError => ~"OtherIoError", + EndOfFile => ~"EndOfFile", + FileNotFound => ~"FileNotFound", + PermissionDenied => ~"PermissionDenied", + ConnectionFailed => ~"ConnectionFailed", + Closed => ~"Closed", + ConnectionRefused => ~"ConnectionRefused", + ConnectionReset => ~"ConnectionReset", + BrokenPipe => ~"BrokenPipe" + } + } +} + // XXX: Can't put doc comments on macros // Raised by `I/O` operations on error. condition! { @@ -505,4 +539,4 @@ pub fn placeholder_error() -> IoError { desc: "Placeholder error. You shouldn't be seeing this", detail: None } -} \ No newline at end of file +} |
