From a152e6f8c69a807dff37232e1837e70a747b7784 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 7 Jul 2019 17:07:48 +0900 Subject: [PATCH] Unify the order of the arguments of read_*_internal functions Unify to the same order as public read_* methods. --- futures-util/src/io/lines.rs | 2 +- futures-util/src/io/read_line.rs | 6 +++--- futures-util/src/io/read_until.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/futures-util/src/io/lines.rs b/futures-util/src/io/lines.rs index b2933fcb66..2e1261689b 100644 --- a/futures-util/src/io/lines.rs +++ b/futures-util/src/io/lines.rs @@ -35,7 +35,7 @@ impl Stream for Lines { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let Self { reader, buf, bytes, read } = unsafe { self.get_unchecked_mut() }; let reader = unsafe { Pin::new_unchecked(reader) }; - let n = ready!(read_line_internal(reader, buf, bytes, read, cx))?; + let n = ready!(read_line_internal(reader, cx, buf, bytes, read))?; if n == 0 && buf.is_empty() { return Poll::Ready(None) } diff --git a/futures-util/src/io/read_line.rs b/futures-util/src/io/read_line.rs index 9517e4e4eb..23e8bb74ce 100644 --- a/futures-util/src/io/read_line.rs +++ b/futures-util/src/io/read_line.rs @@ -32,12 +32,12 @@ impl<'a, R: AsyncBufRead + ?Sized + Unpin> ReadLine<'a, R> { pub(super) fn read_line_internal( reader: Pin<&mut R>, + cx: &mut Context<'_>, buf: &mut String, bytes: &mut Vec, read: &mut usize, - cx: &mut Context<'_>, ) -> Poll> { - let ret = ready!(read_until_internal(reader, b'\n', bytes, read, cx)); + let ret = ready!(read_until_internal(reader, cx, b'\n', bytes, read)); if str::from_utf8(&bytes).is_err() { Poll::Ready(ret.and_then(|_| { Err(io::Error::new(io::ErrorKind::InvalidData, "stream did not contain valid UTF-8")) @@ -56,6 +56,6 @@ impl Future for ReadLine<'_, R> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let Self { reader, buf, bytes, read } = &mut *self; - read_line_internal(Pin::new(reader), buf, bytes, read, cx) + read_line_internal(Pin::new(reader), cx, buf, bytes, read) } } diff --git a/futures-util/src/io/read_until.rs b/futures-util/src/io/read_until.rs index 01e1ad827d..4cb1036670 100644 --- a/futures-util/src/io/read_until.rs +++ b/futures-util/src/io/read_until.rs @@ -25,10 +25,10 @@ impl<'a, R: AsyncBufRead + ?Sized + Unpin> ReadUntil<'a, R> { pub(super) fn read_until_internal( mut reader: Pin<&mut R>, + cx: &mut Context<'_>, byte: u8, buf: &mut Vec, read: &mut usize, - cx: &mut Context<'_>, ) -> Poll> { loop { let (done, used) = { @@ -54,6 +54,6 @@ impl Future for ReadUntil<'_, R> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let Self { reader, byte, buf, read } = &mut *self; - read_until_internal(Pin::new(reader), *byte, buf, read, cx) + read_until_internal(Pin::new(reader), cx, *byte, buf, read) } }