Rust 1.61.0 released
Rust 1.61.0 released
Posted May 27, 2022 15:06 UTC (Fri) by tbelaire (subscriber, #141140)In reply to: Rust 1.61.0 released by excors
Parent article: Rust 1.61.0 released
And a common way to redesign the api is to use an immediately called callback which provides to object you want to restrict, as while it's possible to forget handlers, it is not possible to fail to return. (Well, I guess you can loop forever, but you wouldn't be surprised that the resource is still used then). From crossbeam's documentation.
let array = [1, 2, 3]; crossbeam::scope(|scope| { for i in &array { scope.spawn(move || { println!("element: {}", i); }); } });