diff options
| author | bors <bors@rust-lang.org> | 2018-12-19 12:49:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-19 12:49:32 +0000 |
| commit | 6f839fbb0d407956777529b029fbb0d6cc6e4318 (patch) | |
| tree | 7efc541878cc49a26d67b9eb036d16657c6a5937 /src/libstd | |
| parent | 74ebf026fe927ffa99d541479454f45791806802 (diff) | |
| parent | 1ba6ec4a327d978471cdac31d17d9202106b15bd (diff) | |
| download | rust-6f839fbb0d407956777529b029fbb0d6cc6e4318.tar.gz rust-6f839fbb0d407956777529b029fbb0d6cc6e4318.zip | |
Auto merge of #56977 - pietroalbini:rollup, r=pietroalbini
Rollup of 15 pull requests Successful merges: - #56363 (Defactored Bytes::read) - #56663 (Remove lifetime from Resolver) - #56689 (add a lint group for lints emitted by rustdoc) - #56772 (fix issue 54153 by not testing issue-18804 on Windows nor OS X.) - #56820 (format-related tweaks) - #56881 (Implement Eq, PartialEq and Hash for atomic::Ordering) - #56907 (Fix grammar in compiler error for array iterators) - #56908 (rustc: Don't ICE on usage of two new target features) - #56910 (Do not point at delim spans for complete correct blocks) - #56913 (Enable stack probes for UEFI images) - #56918 (Profiler: simplify total_duration, improve readability) - #56931 (Update release notes for Rust 1.31.1) - #56947 (Add targets thumbv7neon-linux-androideabi and thumbv7neon-unknown-linux-gnueabihf) - #56948 (Update LLVM submodule) - #56959 (Fix mobile menu rendering collision with tooltip.) Failed merges: - #56914 (Ignore ui/target-feature-gate on sparc, sparc64, powerpc, powerpc64 and powerpc64le) r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index dc97701d889..5137a9432ae 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -271,6 +271,7 @@ use cmp; use fmt; +use slice; use str; use memchr; use ptr; @@ -1936,18 +1937,6 @@ impl<T: BufRead> BufRead for Take<T> { } } -fn read_one_byte(reader: &mut dyn Read) -> Option<Result<u8>> { - let mut buf = [0]; - loop { - return match reader.read(&mut buf) { - Ok(0) => None, - Ok(..) => Some(Ok(buf[0])), - Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, - Err(e) => Some(Err(e)), - }; - } -} - /// An iterator over `u8` values of a reader. /// /// This struct is generally created by calling [`bytes`] on a reader. @@ -1965,7 +1954,15 @@ impl<R: Read> Iterator for Bytes<R> { type Item = Result<u8>; fn next(&mut self) -> Option<Result<u8>> { - read_one_byte(&mut self.inner) + let mut byte = 0; + loop { + return match self.inner.read(slice::from_mut(&mut byte)) { + Ok(0) => None, + Ok(..) => Some(Ok(byte)), + Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, + Err(e) => Some(Err(e)), + }; + } } } |
