Skip to content

Commit 28a719f

Browse files
jrmuizelSSheldon
authored andcommitted
Add a generic return type to autoreleasepool()
This is a general usability improvement that lets users easily get values out of the closure.
1 parent c7896cd commit 28a719f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rc/autorelease.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ after the execution of `f` completes.
2424
2525
This corresponds to `@autoreleasepool` blocks in Objective-C and Swift.
2626
*/
27-
pub fn autoreleasepool<F: FnOnce()>(f: F) {
27+
pub fn autoreleasepool<T, F: FnOnce() -> T>(f: F) -> T {
2828
let _context = unsafe { AutoReleaseHelper::new() };
29-
f();
29+
f()
3030
}

0 commit comments

Comments
 (0)