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

Method option_if_none

crates/vm/src/vm/vm_object.rs:103–105  ·  view source on GitHub ↗
(&self, obj: PyObjectRef)

Source from the content-addressed store, hash-verified

101 obj.is(&self.ctx.none)
102 }
103 pub fn option_if_none(&self, obj: PyObjectRef) -> Option<PyObjectRef> {
104 if self.is_none(&obj) { None } else { Some(obj) }
105 }
106 pub fn unwrap_or_none(&self, obj: Option<PyObjectRef>) -> PyObjectRef {
107 obj.unwrap_or_else(|| self.ctx.none())
108 }

Callers 1

py_newMethod · 0.80

Calls 2

SomeClass · 0.50
is_noneMethod · 0.45

Tested by

no test coverage detected