]> git.lizzy.rs Git - rust.git/commitdiff
Use mem::take instead of mem::replace with default
authorChris Gregory <czipperz@gmail.com>
Sun, 30 Jun 2019 18:13:41 +0000 (11:13 -0700)
committerChris Gregory <czipperz@gmail.com>
Tue, 2 Jul 2019 03:21:12 +0000 (20:21 -0700)
src/libcore/option.rs
src/libproc_macro/bridge/buffer.rs

index eec4b149ddc7840e78d0dc5f7a5149c806d43fd4..a2eff0200b77709281f36ec7a9d5c8ea18e76d87 100644 (file)
@@ -845,7 +845,7 @@ pub fn get_or_insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn take(&mut self) -> Option<T> {
-        mem::replace(self, None)
+        mem::take(self)
     }
 
     /// Replaces the actual value in the option by the value given in parameter,
index 0d8cc552d61ab3cdbd86ec1d39f1d6527ddb3aa9..a51e3a9a33d7b542cd823fdbc315bb1ec76e10b2 100644 (file)
@@ -78,7 +78,7 @@ pub(super) fn clear(&mut self) {
     }
 
     pub(super) fn take(&mut self) -> Self {
-        mem::replace(self, Self::default())
+        mem::take(self)
     }
 
     pub(super) fn extend_from_slice(&mut self, xs: &[T]) {