/// Given a list of poker hands, return a list of those hands which win.
///
/// Note the type signature: this function should return _the same_ reference to
/// the winning hand(s) as were passed in, not reconstructed strings which happen to be equal.
Given a list of poker hands, return a list of those hands which win.
Note the type signature: this function should return _the same_ reference to
the winning hand(s) as were passed in, not reconstructed strings which happen to be equal.
Given a list of poker hands return a list of those hands which win . Note the type signature : this function should return _the same_ reference to the winning hand ( s ) as were passed in not reconstructed strings which happen to be equal .
pub fn winning_hands<'a>(hands_raw: &[&'a str]) -> Option<Vec<&'a str>> {
    if hands_raw.is_empty() {
        return Some(vec![]);
    }
    let hands = {
        let mut xs = Vec::with_capacity(hands_raw.len());
        for x in hands_raw.iter() {
            xs.push(Hand::parse(x)?);
        }
        xs.sort_unstable_by(|x, y| y.rank.cmp(&x.rank));
        xs
    };
    Some(
        hands
            .iter()
            .take_while(|x| x.rank == hands[0].rank)
            .map(|x| x.src)
            .collect(),
    )
}
pub fn winning_hands < ' a > ( hands_raw : & [ & ' a str ] ) -> Option < Vec < & ' a str > > { if hands_raw . is_empty ( ) { return Some ( vec ! [ ] ) ; } let hands = { let mut xs = Vec :: with_capacity ( hands_raw . len ( ) ) ; for x in hands_raw . iter ( ) { xs . push ( Hand :: parse ( x ) ? ) ; } xs . sort_unstable_by ( | x , y | y . rank . cmp ( & x . rank ) ) ; xs } ; Some ( hands . iter ( ) . take_while ( | x | x . rank == hands [ 0 ] . rank ) . map ( | x | x . src ) . collect ( ) , ) }
Given a list of poker hands, return a list of those hands which win.
Given a list of poker hands return a list of those hands which win .
hands_raw
&[&'a str]