Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Couldn't compare float number in Rust Lang
fn main() {
let val = vec![1.3, 1.2, 3.0];
for v in val { println!("{}", v); }
Compiling sort v0.1.0 (file:///ome/katsu/Prohgram/Rust/zatsu/rust/nlp100/sort)
error[E0277]: the trait bound `{float}: std::cmp::Ord` is not satisfied
4 | &val.sort();
| ^^^^ the trait `std::cmp::Ord` is not implemented for `{float}`
= help: the following implementations were found:
<&'a A as std::cmp::Ord>
<&'a mut A as std::cmp::Ord>
<str as std::cmp::Ord>
<(A, B, C, D, E, F) as std::cmp::Ord>
and 190 others
error: aborting due to previous error
error: Could not compile `sort`.
To learn more, run the command again with --verbose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment