mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
chore: fix some clippy lints (#3720)
This commit is contained in:
@@ -128,7 +128,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
Poll::Ready(Ok(Some(mem::replace(me.buf, String::new()))))
|
||||
Poll::Ready(Ok(Some(mem::take(me.buf))))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ where
|
||||
{
|
||||
ReadLine {
|
||||
reader,
|
||||
buf: mem::replace(string, String::new()).into_bytes(),
|
||||
buf: mem::take(string).into_bytes(),
|
||||
output: string,
|
||||
read: 0,
|
||||
_pin: PhantomPinned,
|
||||
@@ -99,7 +99,7 @@ pub(super) fn read_line_internal<R: AsyncBufRead + ?Sized>(
|
||||
read: &mut usize,
|
||||
) -> Poll<io::Result<usize>> {
|
||||
let io_res = ready!(read_until_internal(reader, cx, b'\n', buf, read));
|
||||
let utf8_res = String::from_utf8(mem::replace(buf, Vec::new()));
|
||||
let utf8_res = String::from_utf8(mem::take(buf));
|
||||
|
||||
// At this point both buf and output are empty. The allocation is in utf8_res.
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ pub(crate) fn read_to_string<'a, R>(
|
||||
where
|
||||
R: AsyncRead + ?Sized + Unpin,
|
||||
{
|
||||
let buf = mem::replace(string, String::new()).into_bytes();
|
||||
let buf = mem::take(string).into_bytes();
|
||||
ReadToString {
|
||||
reader,
|
||||
buf: VecWithInitialized::new(buf),
|
||||
|
||||
@@ -106,7 +106,7 @@ where
|
||||
me.buf.pop();
|
||||
}
|
||||
|
||||
Poll::Ready(Ok(Some(mem::replace(me.buf, Vec::new()))))
|
||||
Poll::Ready(Ok(Some(mem::take(me.buf))))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ impl BlockingPool {
|
||||
self.spawner.inner.condvar.notify_all();
|
||||
|
||||
let last_exited_thread = std::mem::take(&mut shared.last_exiting_thread);
|
||||
let workers = std::mem::replace(&mut shared.worker_threads, HashMap::new());
|
||||
let workers = std::mem::take(&mut shared.worker_threads);
|
||||
|
||||
drop(shared);
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ impl<T> Receiver<T> {
|
||||
// not memory access.
|
||||
shared.ref_count_rx.fetch_add(1, Relaxed);
|
||||
|
||||
Self { version, shared }
|
||||
Self { shared, version }
|
||||
}
|
||||
|
||||
/// Returns a reference to the most recently sent value
|
||||
|
||||
@@ -296,7 +296,7 @@ impl<T> Slab<T> {
|
||||
|
||||
// Remove the slots vector from the page. This is done so that the
|
||||
// freeing process is done outside of the lock's critical section.
|
||||
let vec = mem::replace(&mut slots.slots, vec![]);
|
||||
let vec = mem::take(&mut slots.slots);
|
||||
slots.head = 0;
|
||||
|
||||
// Drop the lock so we can drop the vector outside the lock below.
|
||||
|
||||
Reference in New Issue
Block a user