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
Require PartialOrd instead of Ord for priorities #31
Conversation
The problem is that relying on PartialOrd can result in a behavior surprisingly wrong or different from what someone wants. In my opinion the best solution in this case is to require the Priority type to be In the specific case of floats, there are also crates that specifically do that: https://crates.io/search?q=ordered%20float |
Thank you for checking out my PR! I think Requiring I still think only requiring the bare minimum trait bounds is the better option, because it gives more information and options to the user. I'm wondering if if would be a better alternative to also allow providing a comparator instead of requiring an Ord instance. If you're still against |
Priority queue most definitely requires I had this same exact issue when I was starting out. Floats not being |
I disagree. You cannot guarantee anything with
It achieves the same thing, with different syntax. That is not insignificant.
I have no issues with restrictions, strong typing, etc "bureaucracy". I started getting into Rust because I wanted a close-to-the-metal Haskell. I merely disagree with the solution to this problem. Thank you all for taking the time to look at this PR and sharing your thoughts! |
Of course we cannot, but if the user implements As a user, I would be very surprised to find out a library smoothed out a requirement and, as a result, I have a bug in my code. |
I was using
priority-queue
for implementing pathfinding and I ran into an issue when trying to use floats as priorities. Priorities requireOrd
, butf32
does not implement it, onlyPartialOrd
. I was curious ifOrd
is really necessary, and as far as I can tell it's not. I replaced allOrd
bounds withPartialOrd
and it still compiled.I'm new to Rust, so please let me know if I missed something.
Thank you!