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

Method drain_entries

crates/vm/src/dict_inner.rs:814–820  ·  view source on GitHub ↗

Pop all entries from the dict, returning (key, value) pairs. This is used for circular reference resolution in GC. Requires &mut self to avoid lock contention.

(&mut self)

Source from the content-addressed store, hash-verified

812 /// This is used for circular reference resolution in GC.
813 /// Requires &mut self to avoid lock contention.
814 pub fn drain_entries(&mut self) -> impl Iterator<Item = (PyObjectRef, T)> + '_ {
815 let inner = self.inner.get_mut();
816 inner.used = 0;
817 inner.filled = 0;
818 inner.indices.iter_mut().for_each(|i| *i = IndexEntry::FREE);
819 inner.entries.drain(..).flatten().map(|e| (e.key, e.value))
820 }
821}
822
823type LookupResult = (IndexEntry, IndexIndex);

Callers 1

clearMethod · 0.80

Calls 5

get_mutMethod · 0.80
iter_mutMethod · 0.45
mapMethod · 0.45
flattenMethod · 0.45
drainMethod · 0.45

Tested by

no test coverage detected