Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix latest clippy assertion failures #910

Merged
merged 11 commits into from
Jun 22, 2021
Prev Previous commit
Next Next commit
Use std::mem::take, which already provides this functionality
Signed-off-by: Thane Thomson <[email protected]>
  • Loading branch information
thanethomson committed Jun 21, 2021
commit 4d3dcf3c1ae2e0dc5066c1b8c44d86cab1226ee1
7 changes: 3 additions & 4 deletions test/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

use std::cmp::min;
use std::io::{self, BufRead, Read, Write};
use std::mem::replace;

use flume::{self, Receiver, SendError, Sender, TrySendError};

Expand Down Expand Up @@ -141,7 +140,7 @@ impl Write for BufWriter {
self.flush()?;
} else {
// reserve capacity later to avoid needless allocations
let data = replace(&mut self.buffer, Vec::new());
let data = std::mem::take(&mut self.buffer);

// buffer still has space but try to send it in case the other side already awaits
match self.sender().try_send(data) {
Expand All @@ -162,7 +161,7 @@ impl Write for BufWriter {
if self.buffer.is_empty() {
Ok(())
} else {
let data = replace(&mut self.buffer, Vec::new());
let data = std::mem::take(&mut self.buffer);
match self.sender().send(data) {
Ok(_) => {
self.buffer.reserve(self.size);
Expand All @@ -184,7 +183,7 @@ impl Write for BufWriter {
impl Drop for BufWriter {
fn drop(&mut self) {
if !self.buffer.is_empty() {
let data = replace(&mut self.buffer, Vec::new());
let data = std::mem::take(&mut self.buffer);
self.sender().send(data).ok();
}
}
Expand Down