about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-10-29 13:48:26 +0100
committerljedrz <ljedrz@gmail.com>2018-10-29 13:48:26 +0100
commit2203ec38cb7fc83122be94c4c269f775e6dedb67 (patch)
tree99c710b89eae00e9b6a9a00db8238242937822c2 /src/librustc_data_structures
parent4e88b7363b7858960ccfd87326ece9d00bf4d973 (diff)
downloadrust-2203ec38cb7fc83122be94c4c269f775e6dedb67.tar.gz
rust-2203ec38cb7fc83122be94c4c269f775e6dedb67.zip
Use opt.take() instead of mem::replace(opt, None)
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/tiny_list.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/librustc_data_structures/tiny_list.rs b/src/librustc_data_structures/tiny_list.rs
index e1bfdf35b27..9dbf0ea9f43 100644
--- a/src/librustc_data_structures/tiny_list.rs
+++ b/src/librustc_data_structures/tiny_list.rs
@@ -22,8 +22,6 @@
 //! If you expect to store more than 1 element in the common case, steer clear
 //! and use a `Vec<T>`, `Box<[T]>`, or a `SmallVec<T>`.
 
-use std::mem;
-
 #[derive(Clone, Hash, Debug, PartialEq)]
 pub struct TinyList<T: PartialEq> {
     head: Option<Element<T>>
@@ -52,7 +50,7 @@ impl<T: PartialEq> TinyList<T> {
     pub fn insert(&mut self, data: T) {
         self.head = Some(Element {
             data,
-            next: mem::replace(&mut self.head, None).map(Box::new),
+            next: self.head.take().map(Box::new)
         });
     }
 
@@ -60,7 +58,7 @@ impl<T: PartialEq> TinyList<T> {
     pub fn remove(&mut self, data: &T) -> bool {
         self.head = match self.head {
             Some(ref mut head) if head.data == *data => {
-                mem::replace(&mut head.next, None).map(|x| *x)
+                head.next.take().map(|x| *x)
             }
             Some(ref mut head) => return head.remove_next(data),
             None => return false,
@@ -100,7 +98,7 @@ impl<T: PartialEq> Element<T> {
             if next.data != *data {
                 return next.remove_next(data)
             } else {
-                mem::replace(&mut next.next, None)
+                next.next.take()
             }
         } else {
             return false