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

Function get_dict_opt_u64

crates/stdlib/src/lzma.rs:222–234  ·  view source on GitHub ↗
(
        spec: &PyObjectRef,
        key: &str,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

220 }
221
222 fn get_dict_opt_u64(
223 spec: &PyObjectRef,
224 key: &str,
225 vm: &VirtualMachine,
226 ) -> PyResult<Option<u64>> {
227 let dict = spec.downcast_ref::<PyDict>().ok_or_else(|| {
228 vm.new_type_error("Filter specifier must be a dict or dict-like object")
229 })?;
230 match dict.get_item_opt(key, vm)? {
231 Some(obj) => Ok(Some(obj.try_into_value::<u64>(vm)?)),
232 None => Ok(None),
233 }
234 }
235
236 fn parse_filter_spec_lzma(spec: &PyObjectRef, vm: &VirtualMachine) -> PyResult<LzmaOptions> {
237 let preset = get_dict_opt_u32(spec, "preset", vm)?.unwrap_or(PRESET_DEFAULT);

Callers 2

parse_filter_chain_specFunction · 0.85

Calls 3

ok_or_elseMethod · 0.80
get_item_optMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected