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

Interface DictKey

crates/vm/src/dict_inner.rs:829–839  ·  view source on GitHub ↗

Types implementing this trait can be used to index the dictionary. Typical use-cases are: - PyObjectRef -> arbitrary python type used as key - str -> string reference used as key, this is often used internally

Source from the content-addressed store, hash-verified

827/// - PyObjectRef -> arbitrary python type used as key
828/// - str -> string reference used as key, this is often used internally
829pub trait DictKey {
830 type Owned: ToPyObject;
831 fn _to_owned(&self, vm: &VirtualMachine) -> Self::Owned;
832 fn to_pyobject(&self, vm: &VirtualMachine) -> PyObjectRef {
833 self._to_owned(vm).to_pyobject(vm)
834 }
835 fn key_hash(&self, vm: &VirtualMachine) -> PyResult<HashValue>;
836 fn key_is(&self, other: &PyObject) -> bool;
837 fn key_eq(&self, vm: &VirtualMachine, other_key: &PyObject) -> PyResult<bool>;
838 fn key_as_isize(&self, vm: &VirtualMachine) -> PyResult<isize>;
839}
840
841/// Implement trait for PyObjectRef such that we can use python objects
842/// to index dictionaries.

Callers 4

insertMethod · 0.45
deleteMethod · 0.45
setdefaultMethod · 0.45
setdefault_entryMethod · 0.45

Implementers 1

dict_inner.rscrates/vm/src/dict_inner.rs

Calls

no outgoing calls

Tested by

no test coverage detected