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

Method try_index_opt

crates/vm/src/protocol/number.rs:27–35  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

25 }
26
27 pub fn try_index_opt(&self, vm: &VirtualMachine) -> Option<PyResult<PyIntRef>> {
28 if let Some(i) = self.downcast_ref_if_exact::<PyInt>(vm) {
29 Some(Ok(i.to_owned()))
30 } else if let Some(i) = self.downcast_ref::<PyInt>() {
31 Some(Ok(vm.ctx.new_bigint(i.as_bigint())))
32 } else {
33 self.number().index(vm)
34 }
35 }
36
37 #[inline]
38 pub fn try_index(&self, vm: &VirtualMachine) -> PyResult<PyIntRef> {

Callers 15

get_raw_sockFunction · 0.80
sendtoMethod · 0.80
try_from_objectMethod · 0.80
subscriptMethod · 0.80
ass_subscriptMethod · 0.80
get_int_or_indexFunction · 0.80
to_isize_indexFunction · 0.80
get_bytearray_innerMethod · 0.80
try_path_or_fdMethod · 0.80
try_indexMethod · 0.80
try_intMethod · 0.80

Calls 6

new_bigintMethod · 0.80
as_bigintMethod · 0.80
numberMethod · 0.80
SomeClass · 0.50
to_ownedMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected