pub fn play(mut decks: (VecDeque<usize>, VecDeque<usize>)) -> (bool, usize) {
    while !decks.0.is_empty() && !decks.1.is_empty() {
        let a = decks.0.pop_front().unwrap();
        let b = decks.1.pop_front().unwrap();
        if a > b {
            decks.0.push_back(a);
            decks.0.push_back(b);
        } else {
            decks.1.push_back(b);
            decks.1.push_back(a);
        }
    }

    (!decks.0.is_empty(), calc_score(if decks.0.is_empty() { &decks.1 } else { &decks.0 }))
}
// tag::play[]
/// Play Combat
///
/// Returns a tuple of a flag indicating the winning player (true for player 1, false for player
/// two) and the winning player's score
:play[]
Play Combat

Returns a tuple of a flag indicating the winning player (true for player 1, false for player
two) and the winning player's score
: play [] Play Combat Returns a tuple of a flag indicating the winning player ( true for player 1 false for player two ) and the winning player ' s score
pub fn play(mut decks: (VecDeque<usize>, VecDeque<usize>)) -> (bool, usize) {
    while !decks.0.is_empty() && !decks.1.is_empty() {
        let a = decks.0.pop_front().unwrap();
        let b = decks.1.pop_front().unwrap();
        if a > b {
            decks.0.push_back(a);
            decks.0.push_back(b);
        } else {
            decks.1.push_back(b);
            decks.1.push_back(a);
        }
    }
    (!decks.0.is_empty(), calc_score(if decks.0.is_empty() { &decks.1 } else { &decks.0 }))
}
pub fn play ( mut decks : ( VecDeque < usize > , VecDeque < usize > ) ) -> ( bool , usize ) { while ! decks . 0 . is_empty ( ) && ! decks . 1 . is_empty ( ) { let a = decks . 0 . pop_front ( ) . unwrap ( ) ; let b = decks . 1 . pop_front ( ) . unwrap ( ) ; if a > b { decks . 0 . push_back ( a ) ; decks . 0 . push_back ( b ) ; } else { decks . 1 . push_back ( b ) ; decks . 1 . push_back ( a ) ; } } ( ! decks . 0 . is_empty ( ) , calc_score ( if decks . 0 . is_empty ( ) { & decks . 1 } else { & decks . 0 } ) ) }
tag::play[]
Play Combat
tag :: play [] Play Combat
decks
(VecDeque<usize>, VecDeque<usize>)
decks
(VecDeque<usize>, VecDeque<usize>)