|
|
|
|
|
by atoav
410 days ago
|
|
I think Result<Option> is the way to go. It describes precisely that: was it Ok? if yes, was there a value? I could imagine situations where an empty return value would constitute an Error, but in 99% of cases returning None would be better. Result<Option> may feel clunky, but if I can give one recommendation when it comes to Rust, is that you should not value your own code-aesthetical feelings too much as it will lead to a lot of pain in many cases — work with the grain of the language not against it even if the result does not satisfy you. In this case I'd highly recommend just using Result<Option> and stop worrying about it. You being able to compose/nest those base types and unwraping or matching them in different sections of your code is a strength not a weakness. |
|