pub fn autoreleasepool<F, R>(f: F) -> Rwhere
F: FnOnce() -> R,Expand description
Execute a closure within an autorelease pool
This is equivalent to @autoreleasepool { ... } in Objective-C/Swift.
Use this when running code that creates temporary Objective-C objects
that need to be released promptly.
The pool is popped by an RAII guard, so it is balanced even if f panics.
Leaking the push would corrupt the thread’s pool stack for every later
pool on that thread, not just this one.
§Example
use screencapturekit::metal::autoreleasepool;
autoreleasepool(|| {
// Code that creates temporary Objective-C objects
println!("Inside autorelease pool");
});