use std::cmp::Ordering; pub struct Result { pub word: usize, pub distance: usize, } impl PartialOrd for Result { fn partial_cmp(&self, other: &Self) -> Option { Some(self.distance.cmp(&other.distance)) .filter(|it| it != &Ordering::Equal) .or_else(|| Some(self.word.cmp(&other.word))) } } impl PartialEq for Result { fn eq(&self, other: &Self) -> bool { self.distance == other.distance && self.word == other.word } } impl Eq for Result {} impl Ord for Result { fn cmp(&self, other: &Self) -> std::cmp::Ordering { match self.distance.cmp(&other.distance) { std::cmp::Ordering::Equal => self.word.cmp(&other.word), std::cmp::Ordering::Greater => std::cmp::Ordering::Greater, std::cmp::Ordering::Less => std::cmp::Ordering::Less, } } } //struct Standing { // size: usize, // results: Vec, //} // //impl Standing { // pub fn new(size: usize) -> Standing { // Standing { // size, // results: BTreeSet::new(), // } // } // // pub fn addResult(&mut self, res: Result) { // self.results.push(res) // } //}