2 ms·
I somehow still prefer ?, even in places where unwrap would be perfectly fine, like tests. unwrap is somehow unpleasant to look at. E.g. you can have tests tha
by rklaehn 6y ago
I somehow still prefer ?, even in places where unwrap would be perfectly fine, like tests. unwrap is somehow unpleasant to look at.
E.g. you can have tests that return an anyhow::Result<()>,
and use ? anywhere in the test. The test will fail if the result is not Ok(()).
Sure, you have the additional boilerplate of the return type annotation and the final Ok(()), but the test logic itself reads nicer, I think.