3 ms·
It's not the same. Using the question mark in a closure in general is confusing. Doing ? on the return value of a statement doesn't make sense. Normally ? is
by WirelessGigabit 4y ago
It's not the same.
Using the question mark in a closure in general is confusing.
Doing ? on the return value of a statement doesn't make sense. Normally ? is used for: here is this Result (I forgot the trait's name), and give me the Ok(), and if it is Err() then RETURN to the caller.
So the function itself must be of type Result<_, _>.
With the lambda in the example it is unclear by reading the code what the ? should do. Stop at the first error and return Err? Or should the return value be Result<Vec<_>, _>?
One can use the try_ functions on an iterator.