-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exec() -> Result<Infallible, Error> ? #7
Comments
This is an interesting idea! I'm a little cautious about touching this crate much, because it has been static for a long time and people may be using it on very old Rust versions. The last release was 7 years ago. But we'd need to bump the semver version, so requiring a more recent Rust might be OK, too. |
If supporting ancient versions of Rust (before 1.34.0, which was where it was stabilized, which was released in 2019) is a concern, you can implement your own Speaking of which, I noticed that your current error type doesn't implement |
Btw, I noticed from #6 that Rust's standard library already has a method that returns only if there's an error, which is what I'm complaining about here. It was stabilized in Rust 1.9, which was released in 2016, just like this library (though a bit later), so I don't know whether to take this as proof that this is alright, or, conversely, that it's an outdated approach that should be changed (but stdlib cannot because of the stability guarantees). |
It's not very common to encounter functions that return if there's an error, and diverge if there is no error. When using this crate, this wasn't very intuitive for me, and I had to check a couple times that unconditionally printing the function's result is actually what I wanted to do.
How about changing the signature of
exec
and friends so that they return aResult
, where theOk
variant is impossible (likestd::convert::Infallible
, or thenever
type once it's stabilized)?Then, the following use clearly indicates that the condition where we remain in the program is exceptional:
or, even shorter:
Also,
unwrap()/expect()
allows you to panic at the spot with the details, rather than adding custom formatting for this.The text was updated successfully, but these errors were encountered: