Skip to content

Commit

Permalink
Unify the order of the arguments of read_*_internal functions
Browse files Browse the repository at this point in the history
Unify to the same order as public read_* methods.
  • Loading branch information
taiki-e authored and cramertj committed Jul 8, 2019
1 parent 4d5743a commit a762a0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion futures-util/src/io/lines.rs
Expand Up @@ -35,7 +35,7 @@ impl<R: AsyncBufRead> Stream for Lines<R> {
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
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)
}
Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/io/read_line.rs
Expand Up @@ -32,12 +32,12 @@ impl<'a, R: AsyncBufRead + ?Sized + Unpin> ReadLine<'a, R> {

pub(super) fn read_line_internal<R: AsyncBufRead + ?Sized>(
reader: Pin<&mut R>,
cx: &mut Context<'_>,
buf: &mut String,
bytes: &mut Vec<u8>,
read: &mut usize,
cx: &mut Context<'_>,
) -> Poll<io::Result<usize>> {
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"))
Expand All @@ -56,6 +56,6 @@ impl<R: AsyncBufRead + ?Sized + Unpin> Future for ReadLine<'_, R> {

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
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)
}
}
4 changes: 2 additions & 2 deletions futures-util/src/io/read_until.rs
Expand Up @@ -25,10 +25,10 @@ impl<'a, R: AsyncBufRead + ?Sized + Unpin> ReadUntil<'a, R> {

pub(super) fn read_until_internal<R: AsyncBufRead + ?Sized>(
mut reader: Pin<&mut R>,
cx: &mut Context<'_>,
byte: u8,
buf: &mut Vec<u8>,
read: &mut usize,
cx: &mut Context<'_>,
) -> Poll<io::Result<usize>> {
loop {
let (done, used) = {
Expand All @@ -54,6 +54,6 @@ impl<R: AsyncBufRead + ?Sized + Unpin> Future for ReadUntil<'_, R> {

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
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)
}
}

0 comments on commit a762a0d

Please sign in to comment.