Skip to content

Commit 19d3a17

Browse files
committed
Simplify remove
1 parent e6bcb29 commit 19d3a17

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,8 @@ impl<K: Eq, V> LinearMap<K, V> {
237237
/// *must* match that of the key type.
238238
pub fn remove<Q: ?Sized + Eq>(&mut self, key: &Q) -> Option<V> where K: Borrow<Q> {
239239
for i in 0..self.storage.len() {
240-
let found;
241-
{
242-
let (ref k, _) = self.storage[i];
243-
found = key == k.borrow();
244-
}
245-
if found {
246-
let (_, v) = self.storage.swap_remove(i);
247-
return Some(v);
240+
if self.storage[i].0.borrow() == key {
241+
return Some(self.storage.swap_remove(i).1);
248242
}
249243
}
250244
None

0 commit comments

Comments
 (0)