Skip to content

Instantly share code, notes, and snippets.

@katsyoshi
Created January 27, 2018 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsyoshi/c76c2f782b3edaeff1d328a84dd582a0 to your computer and use it in GitHub Desktop.
Save katsyoshi/c76c2f782b3edaeff1d328a84dd582a0 to your computer and use it in GitHub Desktop.
Couldn't compare float number in Rust Lang
fn main() {
let val = vec![1.3, 1.2, 3.0];
val.sort();
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
--> main.rs:4:10
|
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