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

Method setdefault

crates/vm/src/builtins/dict.rs:341–349  ·  view source on GitHub ↗
(
        &self,
        key: PyObjectRef,
        default: OptionalArg<PyObjectRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

339
340 #[pymethod]
341 fn setdefault(
342 &self,
343 key: PyObjectRef,
344 default: OptionalArg<PyObjectRef>,
345 vm: &VirtualMachine,
346 ) -> PyResult {
347 self.entries
348 .setdefault(vm, &*key, || default.unwrap_or_none(vm))
349 }
350
351 #[pymethod]
352 pub fn copy(&self) -> Self {

Callers 1

get_or_insertMethod · 0.45

Calls 1

unwrap_or_noneMethod · 0.45

Tested by

no test coverage detected