We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In Sort a Vector of Floats partial_cmp is used, which panics with NaN.
For cases where a vector of floats can contain NaNs there is total_cmp (since Rust 1.64?)
let mut vec = vec![1.1, 1.15, 5.5, 1.123, 2.0, f32::NAN]; vec.sort_by(|a, b| a.total_cmp(b)); assert_eq!(vec[0..5], vec![1.1, 1.123, 1.15, 2.0, 5.5]);
I don't know whether partial_cmp would be preferable if there aren't any NaN.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In Sort a Vector of Floats partial_cmp is used, which panics with NaN.
For cases where a vector of floats can contain NaNs there is total_cmp (since Rust 1.64?)
I don't know whether partial_cmp would be preferable if there aren't any NaN.
The text was updated successfully, but these errors were encountered: