0

I have a vector like this:

let mut v = Vec::new();
v.push((1, 4));
v.push((2, 6));
v.push((3, 5));

How can I find the tuple with the largest second element? In this case it would be (2, 6).

The expression I'm looking for would look like this in python: max(v, key=lambda t: t[1])

fafl
  • 6,782
  • 2
  • 26
  • 45
  • 1
    [The duplicates applied to your situation](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d61ed810bebba8273fc23754c1903691). – Shepmaster Aug 09 '21 at 17:33

0 Answers0