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

Method try_from_pyint

crates/stdlib/src/_opcode.rs:40–51  ·  view source on GitHub ↗
(raw: PyIntRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

38 const HAVE_ARGUMENT: i32 = 43;
39
40 pub fn try_from_pyint(raw: PyIntRef, vm: &VirtualMachine) -> PyResult<Self> {
41 let instruction = raw
42 .try_to_primitive::<u16>(vm)
43 .and_then(|v| {
44 AnyInstruction::try_from(v).map_err(|_| {
45 vm.new_exception_empty(vm.ctx.exceptions.value_error.to_owned())
46 })
47 })
48 .map_err(|_| vm.new_value_error("invalid opcode or oparg"))?;
49
50 Ok(Self(instruction))
51 }
52
53 const fn inner(self) -> AnyInstruction {
54 self.0

Callers

nothing calls this directly

Calls 3

SelfFunction · 0.85
new_exception_emptyMethod · 0.80
to_ownedMethod · 0.45

Tested by

no test coverage detected