Skip to content

Commit a90f57e

Browse files
committed
Apply clippy fixes
1 parent 317c7ea commit a90f57e

29 files changed

+33
-33
lines changed

src/fs/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl LockGuard<State> {
696696
// file. This call should not block because it doesn't touch the actual file on disk.
697697
if pos == SeekFrom::Current(0) {
698698
// Poll the internal file cursor.
699-
let internal = (&*self.file).seek(SeekFrom::Current(0))?;
699+
let internal = (&*self.file).stream_position()?;
700700

701701
// Factor in the difference caused by caching.
702702
let actual = match self.mode {
@@ -714,7 +714,7 @@ impl LockGuard<State> {
714714
if let Some(new) = (start as i64).checked_add(diff) {
715715
if 0 <= new && new <= self.cache.len() as i64 {
716716
// Poll the internal file cursor.
717-
let internal = (&*self.file).seek(SeekFrom::Current(0))?;
717+
let internal = (&*self.file).stream_position()?;
718718

719719
// Adjust the current position in the read cache.
720720
self.mode = Mode::Reading(new as usize);

src/future/poll_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ where
4444
type Output = T;
4545

4646
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
47-
(&mut self.f)(cx)
47+
(self.f)(cx)
4848
}
4949
}

src/io/buf_read/lines.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<R: BufRead> Stream for Lines<R> {
5050
this.buf.pop();
5151
}
5252
}
53-
Poll::Ready(Some(Ok(mem::replace(this.buf, String::new()))))
53+
Poll::Ready(Some(Ok(mem::take(this.buf))))
5454
}
5555
}
5656

@@ -62,7 +62,7 @@ pub fn read_line_internal<R: BufRead + ?Sized>(
6262
read: &mut usize,
6363
) -> Poll<io::Result<usize>> {
6464
let ret = futures_core::ready!(read_until_internal(reader, cx, b'\n', bytes, read));
65-
if str::from_utf8(&bytes).is_err() {
65+
if str::from_utf8(bytes).is_err() {
6666
Poll::Ready(ret.and_then(|_| {
6767
Err(io::Error::new(
6868
io::ErrorKind::InvalidData,

src/io/buf_read/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub trait BufReadExt: BufRead {
136136
{
137137
ReadLineFuture {
138138
reader: self,
139-
bytes: unsafe { mem::replace(buf.as_mut_vec(), Vec::new()) },
139+
bytes: unsafe { std::mem::take(buf.as_mut_vec()) },
140140
buf,
141141
read: 0,
142142
}

src/io/buf_read/read_line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<T: BufRead + Unpin + ?Sized> Future for ReadLineFuture<'_, T> {
2929
let reader = Pin::new(reader);
3030

3131
let ret = futures_core::ready!(read_until_internal(reader, cx, b'\n', bytes, read));
32-
if str::from_utf8(&bytes).is_err() {
32+
if str::from_utf8(bytes).is_err() {
3333
Poll::Ready(ret.and_then(|_| {
3434
Err(io::Error::new(
3535
io::ErrorKind::InvalidData,

src/io/buf_read/split.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ impl<R: BufRead> Stream for Split<R> {
4646
if this.buf[this.buf.len() - 1] == *this.delim {
4747
this.buf.pop();
4848
}
49-
Poll::Ready(Some(Ok(mem::replace(this.buf, vec![]))))
49+
Poll::Ready(Some(Ok(mem::take(this.buf))))
5050
}
5151
}

src/io/read/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
144144
let this = self.project();
145145
if !*this.done_first {
146146
match futures_core::ready!(this.first.poll_fill_buf(cx)) {
147-
Ok(buf) if buf.is_empty() => {
147+
Ok([]) => {
148148
*this.done_first = true;
149149
}
150150
Ok(buf) => return Poll::Ready(Ok(buf)),

src/io/read/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub trait ReadExt: Read {
168168
let start_len = buf.len();
169169
ReadToStringFuture {
170170
reader: self,
171-
bytes: unsafe { mem::replace(buf.as_mut_vec(), Vec::new()) },
171+
bytes: unsafe { mem::take(buf.as_mut_vec()) },
172172
buf,
173173
start_len,
174174
}

src/io/read/read_exact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<T: Read + Unpin + ?Sized> Future for ReadExactFuture<'_, T> {
2020

2121
while !buf.is_empty() {
2222
let n = futures_core::ready!(Pin::new(&mut *reader).poll_read(cx, buf))?;
23-
let (_, rest) = mem::replace(buf, &mut []).split_at_mut(n);
23+
let (_, rest) = mem::take(buf).split_at_mut(n);
2424
*buf = rest;
2525

2626
if n == 0 {

src/io/read/read_to_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<T: Read + Unpin + ?Sized> Future for ReadToStringFuture<'_, T> {
2929
let reader = Pin::new(reader);
3030

3131
let ret = futures_core::ready!(read_to_end_internal(reader, cx, bytes, *start_len));
32-
if str::from_utf8(&bytes).is_err() {
32+
if str::from_utf8(bytes).is_err() {
3333
Poll::Ready(ret.and_then(|_| {
3434
Err(io::Error::new(
3535
io::ErrorKind::InvalidData,

0 commit comments

Comments
 (0)