diff options
author | Zahari Dichev <zaharidichev@gmail.com> | 2020-09-05 21:09:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 11:09:54 -0700 |
commit | 171cb57fa1baffe369e44e1bf28382dcb54b2e1c (patch) | |
tree | 8c641360979e85a004b927fd70d38fd719745166 /tokio/src/io/util | |
parent | c9f5bc29158a6f3a786e9d67df8da31524e8a9c3 (diff) |
io: add `ReadBuf::take` (#2817)
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
Diffstat (limited to 'tokio/src/io/util')
-rw-r--r-- | tokio/src/io/util/take.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/tokio/src/io/util/take.rs b/tokio/src/io/util/take.rs index 2abc7693..4e424f6c 100644 --- a/tokio/src/io/util/take.rs +++ b/tokio/src/io/util/take.rs @@ -85,10 +85,7 @@ impl<R: AsyncRead> AsyncRead for Take<R> { } let me = self.project(); - let max = std::cmp::min(buf.remaining() as u64, *me.limit_) as usize; - // Make a ReadBuf of the unfulled section up to max - // Saftey: We don't set any of the `unfilled_mut` with `MaybeUninit::uninit`. - let mut b = unsafe { ReadBuf::uninit(&mut buf.unfilled_mut()[..max]) }; + let mut b = buf.take(*me.limit_ as usize); ready!(me.inner.poll_read(cx, &mut b))?; let n = b.filled().len(); |