rust/hedgewars-server/src/server/indexslab.rs
changeset 14693 6a2e13e36b7f
parent 14692 e5415faa117b
--- a/rust/hedgewars-server/src/server/indexslab.rs	Thu Feb 07 14:49:51 2019 +0300
+++ b/rust/hedgewars-server/src/server/indexslab.rs	Thu Feb 07 17:02:24 2019 +0300
@@ -1,5 +1,6 @@
 use std::{
     iter,
+    mem::replace,
     ops::{Index, IndexMut},
 };
 
@@ -32,9 +33,11 @@
         self.data.get(index).and_then(|x| x.as_ref()).is_some()
     }
 
-    pub fn remove(&mut self, index: usize) {
+    pub fn remove(&mut self, index: usize) -> Option<T> {
         if let Some(x) = self.data.get_mut(index) {
-            *x = None
+            replace(x, None)
+        } else {
+            None
         }
     }