I have code that uses scoped_threadpool something like this:
extern crate scoped_threadpool; use scoped_threadpool::Pool; use std::error::Error; fn main() { inner_main().unwrap(); } fn inner_main() -> Result<(), Box<Error>> { let mut pool = Pool::new(2); pool.scoped(|scope| { scope.execute(move || { // This changed to become fallible fallible_code(); }); }); Ok(()) } fn fallible_code() -> Result<(), Box<Error + Send + Sync>> { Err(From::from("Failing")) }
The fallible_code
function fallible_code
recently changed to return a Result
, and I would like to propagate the error outside the pool.scoped
block. However, the signature of Scope::execute
does not allow returning the value:
fn execute<F>(&self, f: F) where F: FnOnce() + Send + 'scope
I am using scoped_threadpool 0.1.7.
source share