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

Function hash_wrapper

crates/vm/src/types/slot.rs:486–497  ·  view source on GitHub ↗
(zelf: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

484}
485
486fn hash_wrapper(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<PyHash> {
487 let hash_obj = vm.call_special_method(zelf, identifier!(vm, __hash__), ())?;
488 let py_int = hash_obj
489 .downcast_ref::<PyInt>()
490 .ok_or_else(|| vm.new_type_error("__hash__ method should return an integer"))?;
491 let big_int = py_int.as_bigint();
492 let hash = big_int
493 .to_i64()
494 .map(fix_sentinel)
495 .unwrap_or_else(|| hash_bigint(big_int));
496 Ok(hash)
497}
498
499/// Marks a type as unhashable. Similar to PyObject_HashNotImplemented in CPython
500pub fn hash_not_implemented(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<PyHash> {

Callers

nothing calls this directly

Calls 5

hash_bigintFunction · 0.85
call_special_methodMethod · 0.80
ok_or_elseMethod · 0.80
as_bigintMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected