From 03fa5be4590abc32b8294f105c3e3a873ab16b50 Mon Sep 17 00:00:00 2001 From: "Hugo E.-Lahsen - xy2_" Date: Thu, 5 Jan 2023 11:20:31 +0100 Subject: [PATCH] borrow-splitting: Use `take` instead of `replace` (#391) --- src/borrow-splitting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borrow-splitting.md b/src/borrow-splitting.md index 3d13ff9..08b6d0d 100644 --- a/src/borrow-splitting.md +++ b/src/borrow-splitting.md @@ -159,7 +159,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { type Item = &'a mut T; fn next(&mut self) -> Option { - let slice = mem::replace(&mut self.0, &mut []); + let slice = mem::take(&mut self.0); if slice.is_empty() { return None; } 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> { fn next_back(&mut self) -> Option { - let slice = mem::replace(&mut self.0, &mut []); + let slice = mem::take(&mut self.0); if slice.is_empty() { return None; } let new_len = slice.len() - 1;