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

Function try_defer_drop

crates/common/src/refcount.rs:248–261  ·  view source on GitHub ↗
(f: F)

Source from the content-addressed store, hash-verified

246#[cfg(feature = "std")]
247#[inline]
248pub fn try_defer_drop<F>(f: F)
249where
250 F: FnOnce() + 'static,
251{
252 let should_defer = IN_DEFERRED_CONTEXT.with(|in_ctx| in_ctx.get());
253
254 if should_defer {
255 DEFERRED_QUEUE.with(|q| {
256 q.borrow_mut().push(Box::new(f));
257 });
258 } else {
259 f();
260 }
261}
262
263/// Flush all deferred drop operations.
264/// This is automatically called when exiting a deferred context.

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
withMethod · 0.80
borrow_mutMethod · 0.80
fFunction · 0.50
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected