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

Method enter

crates/vm/src/recursion.rs:12–23  ·  view source on GitHub ↗

Returns None if the guard against 'obj' is still held otherwise returns the guard. The guard which is released if dropped.

(vm: &'vm VirtualMachine, obj: &PyObject)

Source from the content-addressed store, hash-verified

10 /// Returns None if the guard against 'obj' is still held otherwise returns the guard. The guard
11 /// which is released if dropped.
12 pub fn enter(vm: &'vm VirtualMachine, obj: &PyObject) -> Option<Self> {
13 let mut guards = vm.repr_guards.borrow_mut();
14
15 // Should this be a flag on the obj itself? putting it in a global variable for now until it
16 // decided the form of PyObject. https://github.com/RustPython/RustPython/issues/371
17 let id = obj.get_id();
18 if guards.contains(&id) {
19 return None;
20 }
21 guards.insert(id);
22 Some(ReprGuard { vm, id })
23 }
24}
25
26impl Drop for ReprGuard<'_> {

Callers 10

newMethod · 0.45
thenMethod · 0.45
newMethod · 0.45
with_vmMethod · 0.45
py_to_jsFunction · 0.45
request_animation_frameFunction · 0.45
load_moduleFunction · 0.45
test_print_42Function · 0.45
test_insertFunction · 0.45
check_hash_equivalenceFunction · 0.45

Calls 5

borrow_mutMethod · 0.80
SomeClass · 0.50
get_idMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45

Tested by 2

test_print_42Function · 0.36
test_insertFunction · 0.36