From b3d33feaf79576d625d2c3540c0ad37569c43a3a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 8 Sep 2019 20:20:08 -0700 Subject: [PATCH] Use swap_remove on IndexMap Plain remove is deprecated. --- src/map.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/map.rs b/src/map.rs index 642463032..3ef3811b1 100644 --- a/src/map.rs +++ b/src/map.rs @@ -126,7 +126,10 @@ impl Map { String: Borrow, Q: Ord + Eq + Hash, { - self.map.remove(key) + #[cfg(feature = "preserve_order")] + return self.map.swap_remove(key); + #[cfg(not(feature = "preserve_order"))] + return self.map.remove(key); } /// Gets the given key's corresponding entry in the map for in-place @@ -692,7 +695,10 @@ impl<'a> OccupiedEntry<'a> { /// ``` #[inline] pub fn remove(self) -> Value { - self.occupied.remove() + #[cfg(feature = "preserve_order")] + return self.occupied.swap_remove(); + #[cfg(not(feature = "preserve_order"))] + return self.occupied.remove(); } }