Stabilize Termination and ExitCode by yaahc · Pull Request #93840 · rust-lang/rust (original) (raw)
The current ExitCode is essentially write-only in the sense that once created, a consumer external to std cannot readily inspect whether it represents success or failure. If we add a trivial PartialEq impl, then consumers would be able to == against the SUCCESS or FAILURE constants, but this would either need some care to deal with other failure statuses (where FAILURE is 1, but someone has used From<u8>
from 3) or unusual equality impls that consider everything nonzero equivalent.
If the intent is to leave the struct opaque indefinitely (essentially that it can only lead to process::exit in std) then that seems OK, but if the intent is to support manipulating ExitCodes then it seems less clear that the current design is the right one.
I am also a little concerned with potential confusion around ExitStatus vs. ExitCode -- they're both in std::process, with one for the result of running a Command and the other for (presumably) exiting from the current process. This distinction is somewhat subtle and I think it's worthwhile to add a paragraph to the documentation of each at least pointing at the other type.
The warning text on ExitCode should probably also be removed if we're stabilizing it ("Warning: While various forms of this were discussed in RFC #1937, it was ultimately cut from that RFC, and thus this type is more subject to change even than the usual unstable item churn.")