These are chat archives for rust-lang/rust

23rd
Jul 2016
Nico Ritschel
@nicosuave
Jul 23 2016 21:12
How can I call max_by on a Vec<String>? I initially tried .to_iter().max_by…
Rust
@LooMaclin
Jul 23 2016 21:21
@nicosuave hi! look this sample https://is.gd/Q8xNoW
Nico Ritschel
@nicosuave
Jul 23 2016 21:25
That seems to work with say, a Vec<f32>, @LooMaclin
Rust
@LooMaclin
Jul 23 2016 21:27
@nicosuave yep, sorry, this correct sample https://is.gd/Iahary with Vec<String>
or you're looking for something else?
Nico Ritschel
@nicosuave
Jul 23 2016 21:30
Here’s what I’m seeing
src/main.rs:113:10: 113:20 error: the trait bound `f32: std::cmp::Ord` is not satisfied [E0277]
src/main.rs:113         .max_by_key(|&(_, path)| score(&path, &cleansed_path));
                         ^~~~~~~~~~
Signature for score is:
fn score(s1: &String, s2: &String) -> f32
This message was deleted
Nico Ritschel
@nicosuave
Jul 23 2016 21:41
Ahh, so there’s no Ord for f32
Rust
@LooMaclin
Jul 23 2016 21:46
@nicosuave yes, the standart library not implemented Ord trait for float types, but it implemented PartialOrd, and this sample for you https://is.gd/UsbhpJ
Nico Ritschel
@nicosuave
Jul 23 2016 22:19
Very much appreciated @LooMaclin