The double question mark is because Tokio more closely mirrors the API of the standard library for this API, which says that joining a
JoinHandle should return a
Result<T, JoinError> where
T is the return value of the spawned task.
Since the task returns
Result<f64, io::Error>, this results in the return value of
Result<Result<f64, io::Error>, JoinError>
and to unwrap a twice-nested
Result requires two question marks.
In async-std, they have an unwrap inside the
.await that removes the need for you to have the outer
Note that a
JoinError happens mainly if the spawned task panics.
Note that comparing to this:
.unwrap() then question mark handles the same problem where the standard library gives you a double-nested result, except you handle the inner one by unwrapping rather than with a question mark.
Again, with async-std, you would still panic in the same case, the unwrap is just somewhere inside the impl of
.await on a
JoinHandle, so you don't have to do it.