kernel
kernel copied to clipboard
Refactor to use TryFrom
Since the TryFrom trait is in unstable Rust (rust-lang/rust#33417), we should rewrite a lot of failable conversions into TryFrom implementations. For example, a lot of the ELF parsing code that returns Result<Self, ElfError> can probably be rewritten to use TryFrom.
Where removing existing failable conversion methods would break a lot of other code, we can temporarily preserve the existing API by having it wrap a try_from call, and phase it out gradually.
We don't have to worry about TryFrom not being on stable, since we can't build SOS on stable anyway.
I'm marking this as "easy" since it is a reasonably simple refactoring that doesn't require a great deal of OS knowledge.
As an update to the issue the above RFC was implemented and merged with PR : https://github.com/rust-lang/rust/pull/49305 . It caused notable breakages in the ecosystem and got reverted : https://github.com/rust-lang/rust/pull/49518
@tirkarthi my understanding is that all that was reverted is the addition of TryFrom to the prelude, the traits are still stabilized, correct?
Yes, the team is looking for a way to introduce this with less breakages.