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

Method clear

crates/vm/src/builtins/list.rs:70–77  ·  view source on GitHub ↗
(&mut self, out: &mut Vec<PyObjectRef>)

Source from the content-addressed store, hash-verified

68 }
69
70 fn clear(&mut self, out: &mut Vec<PyObjectRef>) {
71 // During GC, we use interior mutability to access elements.
72 // This is safe because during GC collection, the object is unreachable
73 // and no other code should be accessing it.
74 if let Some(mut guard) = self.elements.try_write() {
75 out.extend(guard.drain(..));
76 }
77 }
78}
79
80thread_local! {

Callers

nothing calls this directly

Calls 5

takeFunction · 0.85
borrow_vec_mutMethod · 0.80
extendMethod · 0.45
drainMethod · 0.45
deref_mutMethod · 0.45

Tested by

no test coverage detected