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

Rollup of 5 pull requests #110648

Merged
merged 10 commits into from
Apr 21, 2023
2 changes: 1 addition & 1 deletion library/alloc/src/vec/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
}
}

let iter = mem::replace(&mut self.iter, (&mut []).iter());
let iter = mem::take(&mut self.iter);
let drop_len = iter.len();

let mut vec = self.vec;
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/slice/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ where
None
} else {
self.finished = true;
Some(mem::replace(&mut self.v, &mut []))
Some(mem::take(&mut self.v))
}
}
}
Expand Down Expand Up @@ -749,7 +749,7 @@ where
match idx_opt {
None => self.finish(),
Some(idx) => {
let tmp = mem::replace(&mut self.v, &mut []);
let tmp = mem::take(&mut self.v);
let (head, tail) = tmp.split_at_mut(idx);
self.v = head;
Some(&mut tail[1..])
Expand Down Expand Up @@ -830,7 +830,7 @@ where
if idx == self.v.len() {
self.finished = true;
}
let tmp = mem::replace(&mut self.v, &mut []);
let tmp = mem::take(&mut self.v);
let (head, tail) = tmp.split_at_mut(idx);
self.v = tail;
Some(head)
Expand Down Expand Up @@ -876,7 +876,7 @@ where
if idx == 0 {
self.finished = true;
}
let tmp = mem::replace(&mut self.v, &mut []);
let tmp = mem::take(&mut self.v);
let (head, tail) = tmp.split_at_mut(idx);
self.v = head;
Some(tail)
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl Write for &mut [u8] {
#[inline]
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
let amt = cmp::min(data.len(), self.len());
let (a, b) = mem::replace(self, &mut []).split_at_mut(amt);
let (a, b) = mem::take(self).split_at_mut(amt);
a.copy_from_slice(&data[..amt]);
*self = b;
Ok(amt)
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod tests;

use crate::cmp;
use crate::fmt;
use crate::mem::replace;
use crate::mem::take;
use crate::ops::{Deref, DerefMut};
use crate::slice;
use crate::str;
Expand Down Expand Up @@ -1186,7 +1186,7 @@ impl<'a> IoSliceMut<'a> {
}
}

*bufs = &mut replace(bufs, &mut [])[remove..];
*bufs = &mut take(bufs)[remove..];
if bufs.is_empty() {
assert!(n == accumulated_len, "advancing io slices beyond their length");
} else {
Expand Down Expand Up @@ -1329,7 +1329,7 @@ impl<'a> IoSlice<'a> {
}
}

*bufs = &mut replace(bufs, &mut [])[remove..];
*bufs = &mut take(bufs)[remove..];
if bufs.is_empty() {
assert!(n == accumulated_len, "advancing io slices beyond their length");
} else {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unsupported/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'a> IoSliceMut<'a> {

#[inline]
pub fn advance(&mut self, n: usize) {
let slice = mem::replace(&mut self.0, &mut []);
let slice = mem::take(&mut self.0);
let (_, remaining) = slice.split_at_mut(n);
self.0 = remaining;
}
Expand Down