pred should be VERY CAREFUL about what it does as it is called while the dict's internal mutex is held
(
&self,
vm: &VirtualMachine,
key: &K,
pred: F,
)
| 468 | /// pred should be VERY CAREFUL about what it does as it is called while |
| 469 | /// the dict's internal mutex is held |
| 470 | pub(crate) fn remove_if<K, F>( |
| 471 | &self, |
| 472 | vm: &VirtualMachine, |
| 473 | key: &K, |
| 474 | pred: F, |
| 475 | ) -> PyResult<Option<T>> |
| 476 | where |
| 477 | K: DictKey + ?Sized, |
| 478 | F: Fn(&T) -> PyResult<bool>, |
| 479 | { |
| 480 | let hash = key.key_hash(vm)?; |
| 481 | let removed = loop { |
| 482 | let lookup = self.lookup(vm, key, hash, None)?; |
| 483 | match self.pop_inner_if(lookup, &pred)? { |
| 484 | ControlFlow::Break(entry) => break entry, |
| 485 | ControlFlow::Continue(()) => continue, |
| 486 | } |
| 487 | }; |
| 488 | Ok(removed.map(|entry| entry.value)) |
| 489 | } |
| 490 | |
| 491 | pub fn delete_or_insert(&self, vm: &VirtualMachine, key: &PyObject, value: T) -> PyResult<()> { |
| 492 | let hash = key.key_hash(vm)?; |
no test coverage detected