Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Deprecate `ok_or` method #51292
There is plenty of issues when people unintendely use the eager version of mapping result method just because it saves some typing. It results in confusion among the community as well as performance issues in compiler.
Rust is going into the new epoch, so it's a good time to resolve this mistake.
The proposal is:
The phase 2 looks a bit confusing, but as said it would save some typing. Or it could be done in one big step. It would break the existing code, however it's an ok breakage as it's easy to fix it automatically (via just
This probably requires an RFC, I didn't do one yet, but I think we may collect some feedback here. Do you feel that compiler is smart enough to inline constant functions and we can remove some confusion and possible bottlenecks? Do you accept to type a bit more (
In my expirience you almost never want to return just a const. All errors in common libraries follow this pattern