diff options
| author | bors <bors@rust-lang.org> | 2014-12-04 21:33:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-04 21:33:07 +0000 |
| commit | d9c7c00b9a3d80fc81fbbb77a9f21e5f71a1d213 (patch) | |
| tree | df2148f08e426cc9f26fe74fa2409cfbbcb10f3c /src/libcore | |
| parent | 4053e82acb125e04a11f7328de7c86d314b70a9f (diff) | |
| parent | 298b525951ea4ce7a78364e835f45a549b7f865e (diff) | |
| download | rust-d9c7c00b9a3d80fc81fbbb77a9f21e5f71a1d213.tar.gz rust-d9c7c00b9a3d80fc81fbbb77a9f21e5f71a1d213.zip | |
auto merge of #18980 : erickt/rust/reader, r=erickt
This continues the work @thestinger started in #18885 (which hasn't landed yet, so wait for that to land before landing this one). Instead of adding more methods to `BufReader`, this just allows a `&[u8]` to be used directly as a `Reader`. It also adds an impl of `Writer` for `&mut [u8]`.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/result.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 07bb6f15c94..7c88106c9ec 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -444,15 +444,14 @@ impl<T, E> Result<T, E> { /// ignoring I/O and parse errors: /// /// ``` - /// use std::io::{BufReader, IoResult}; + /// use std::io::IoResult; /// - /// let buffer = "1\n2\n3\n4\n"; - /// let mut reader = BufReader::new(buffer.as_bytes()); + /// let mut buffer = &mut b"1\n2\n3\n4\n"; /// /// let mut sum = 0; /// - /// while !reader.eof() { - /// let line: IoResult<String> = reader.read_line(); + /// while !buffer.is_empty() { + /// let line: IoResult<String> = buffer.read_line(); /// // Convert the string line to a number using `map` and `from_str` /// let val: IoResult<int> = line.map(|line| { /// from_str::<int>(line.as_slice().trim_right()).unwrap_or(0) |
