You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. Thanks for this nice crate. I have only been using it a few hours and it is already improving my life. I have found a situation where I can write something with an obvious meaning but which doesn't do what I would have hoped:
This function
#[must_use] #[throws(X)] fn x() -> usize { 42 }
can be called, and the value 42 discarded, without any warning. This is probably not what the programmer intended when they wrote #[must_use].
I suspect that fixing this is not going to be simple. When considering Rust without Fehler, there does not appear to be a way to write a function that returns a Result<T,E> where the caller is required to both handle E and do something with T. (Other than making the whole type T must_use, which may not be desirable or possible.)
Would it be easy to spot this case and at least warn about it? [throws] implies that the Result must be used. So adding [must_use] is an attempt to do this sadly-impossible thing and it would be nice to let the programmer know that this constraint wasn't going to be enforced.
Hi. Thanks for this nice crate. I have only been using it a few hours and it is already improving my life. I have found a situation where I can write something with an obvious meaning but which doesn't do what I would have hoped:
This function
can be called, and the value 42 discarded, without any warning. This is probably not what the programmer intended when they wrote
#[must_use]
.I suspect that fixing this is not going to be simple. When considering Rust without Fehler, there does not appear to be a way to write a function that returns a Result<T,E> where the caller is required to both handle E and do something with T. (Other than making the whole type T must_use, which may not be desirable or possible.)
My full test program:
The text was updated successfully, but these errors were encountered: