borrow-splitting: Use `take` instead of `replace` (#391)

pull/392/head
Hugo E.-Lahsen - xy2_ 2 years ago committed by GitHub
parent 8ca2612680
commit 03fa5be459
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -159,7 +159,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
type Item = &'a mut T; type Item = &'a mut T;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let slice = mem::replace(&mut self.0, &mut []); let slice = mem::take(&mut self.0);
if slice.is_empty() { return None; } if slice.is_empty() { return None; }
let (l, r) = slice.split_at_mut(1); let (l, r) = slice.split_at_mut(1);
@ -170,7 +170,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
fn next_back(&mut self) -> Option<Self::Item> { fn next_back(&mut self) -> Option<Self::Item> {
let slice = mem::replace(&mut self.0, &mut []); let slice = mem::take(&mut self.0);
if slice.is_empty() { return None; } if slice.is_empty() { return None; }
let new_len = slice.len() - 1; let new_len = slice.len() - 1;

Loading…
Cancel
Save