diff options
| author | Steven Fackler <sfackler@gmail.com> | 2021-01-11 07:48:24 -0500 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2021-01-11 07:48:24 -0500 |
| commit | a9ef7983a629fea829955608d67f474f856da53c (patch) | |
| tree | 491677252fee1e7b57aeea56a721ae4f7f0c3d88 | |
| parent | ebe402dc9e708a8ed5e5860a7b30ea7826ab52a1 (diff) | |
| download | rust-a9ef7983a629fea829955608d67f474f856da53c.tar.gz rust-a9ef7983a629fea829955608d67f474f856da53c.zip | |
clean up control flow
| -rw-r--r-- | library/std/src/io/mod.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 0bc0e0e8e83..a054c434d07 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -366,7 +366,6 @@ where { let start_len = buf.len(); let mut g = Guard { len: buf.len(), buf }; - let ret; loop { if g.len == g.buf.len() { unsafe { @@ -386,10 +385,7 @@ where } match r.read(&mut g.buf[g.len..]) { - Ok(0) => { - ret = Ok(g.len - start_len); - break; - } + Ok(0) => return Ok(g.len - start_len), Ok(n) => { // We can't let g.len overflow which would result in the vec shrinking when the function returns. In // particular, that could break read_to_string if the shortened buffer doesn't end on a UTF-8 boundary. @@ -399,14 +395,9 @@ where g.len += n; } Err(ref e) if e.kind() == ErrorKind::Interrupted => {} - Err(e) => { - ret = Err(e); - break; - } + Err(e) => return Err(e), } } - - ret } pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize> |
