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

Method cast

crates/wasm/src/js_module.rs:434–442  ·  view source on GitHub ↗
(obj: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

432 }
433
434 fn cast(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<Self> {
435 let then = vm.get_attribute_opt(obj.clone(), "then")?;
436 let value = if let Some(then) = then.filter(|obj| obj.is_callable()) {
437 PromiseKind::PyProm { then }
438 } else {
439 PromiseKind::PyResolved(obj)
440 };
441 Ok(Self { value })
442 }
443
444 fn cast_result(res: PyResult, vm: &VirtualMachine) -> PyResult<Self> {
445 match res {

Callers 15

recvmsgMethod · 0.45
pack_cmsgs_to_sendMethod · 0.45
collation_callbackMethod · 0.45
trace_callbackMethod · 0.45
backupMethod · 0.45
create_functionMethod · 0.45
create_aggregateMethod · 0.45
create_collationMethod · 0.45
set_authorizerMethod · 0.45
set_trace_callbackMethod · 0.45
set_progress_handlerMethod · 0.45

Calls 4

get_attribute_optMethod · 0.80
is_callableMethod · 0.80
cloneMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected