Created
January 27, 2018 11:25
-
-
Save katsyoshi/c76c2f782b3edaeff1d328a84dd582a0 to your computer and use it in GitHub Desktop.
Couldn't compare float number in Rust Lang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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