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

Function get_opt_int_field

crates/vm/src/stdlib/_ast.rs:178–190  ·  view source on GitHub ↗
(
    vm: &VirtualMachine,
    obj: &PyObject,
    field: &'static str,
)

Source from the content-addressed store, hash-verified

176}
177
178fn get_opt_int_field(
179 vm: &VirtualMachine,
180 obj: &PyObject,
181 field: &'static str,
182) -> PyResult<Option<PyRefExact<PyInt>>> {
183 match get_node_field_opt(vm, obj, field)? {
184 Some(val) => val
185 .downcast_exact(vm)
186 .map(Some)
187 .map_err(|_| vm.new_type_error(format!(r#"field "{field}" must have integer type"#))),
188 None => Ok(None),
189 }
190}
191
192fn range_from_object(
193 vm: &VirtualMachine,

Callers 1

range_from_objectFunction · 0.85

Calls 3

get_node_field_optFunction · 0.85
downcast_exactMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected