MCPcopy Index your code
hub / github.com/RustPython/RustPython / delete

Method delete

crates/vm/src/dict_inner.rs:435–444  ·  view source on GitHub ↗

Delete a key

(&self, vm: &VirtualMachine, key: &K)

Source from the content-addressed store, hash-verified

433
434 /// Delete a key
435 pub fn delete<K>(&self, vm: &VirtualMachine, key: &K) -> PyResult<()>
436 where
437 K: DictKey + ?Sized,
438 {
439 if self.remove_if_exists(vm, key)?.is_some() {
440 Ok(())
441 } else {
442 Err(vm.new_key_error(key.to_pyobject(vm)))
443 }
444 }
445
446 pub fn delete_if_exists<K>(&self, vm: &VirtualMachine, key: &K) -> PyResult<bool>
447 where

Callers 3

test_insertFunction · 0.45
inner_delitemMethod · 0.45
removeMethod · 0.45

Calls 4

remove_if_existsMethod · 0.80
new_key_errorMethod · 0.80
ErrClass · 0.50
to_pyobjectMethod · 0.45

Tested by 1

test_insertFunction · 0.36