mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-25 13:24:22 +00:00
clean up control flow
This commit is contained in:
parent
ebe402dc9e
commit
a9ef7983a6
@ -366,7 +366,6 @@ where
|
|||||||
{
|
{
|
||||||
let start_len = buf.len();
|
let start_len = buf.len();
|
||||||
let mut g = Guard { len: buf.len(), buf };
|
let mut g = Guard { len: buf.len(), buf };
|
||||||
let ret;
|
|
||||||
loop {
|
loop {
|
||||||
if g.len == g.buf.len() {
|
if g.len == g.buf.len() {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -386,10 +385,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
match r.read(&mut g.buf[g.len..]) {
|
match r.read(&mut g.buf[g.len..]) {
|
||||||
Ok(0) => {
|
Ok(0) => return Ok(g.len - start_len),
|
||||||
ret = Ok(g.len - start_len);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
// We can't let g.len overflow which would result in the vec shrinking when the function returns. In
|
// 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.
|
// particular, that could break read_to_string if the shortened buffer doesn't end on a UTF-8 boundary.
|
||||||
@ -399,16 +395,11 @@ where
|
|||||||
g.len += n;
|
g.len += n;
|
||||||
}
|
}
|
||||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||||
Err(e) => {
|
Err(e) => return Err(e),
|
||||||
ret = Err(e);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
|
pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut [u8]) -> Result<usize>,
|
F: FnOnce(&mut [u8]) -> Result<usize>,
|
||||||
|
Loading…
Reference in New Issue
Block a user