/// Checks whether the cards in a foundation have the required suit and are in the correct order.
Checks whether the cards in a foundation have the required suit and are in the correct order.
Checks whether the cards in a foundation have the required suit and are in the correct order .
fn check_foundation(foundation: &Foundation, suit: Suit) -> Result<(), String> {
    for (i, card) in foundation.iter().enumerate() {
        if card.suit != suit {
            return Err(format!(
                "Foundation of suit {} contains card of suit {}: {}",
                suit, card.suit, card
            ));
        }
        if card.rank != 1 + i as u8 {
            return Err(format!(
                "Foundation of suit {} contains card of rank {} at position {}",
                suit, card.rank, i + 1
            ));
        }
    }
    Ok(())
}
fn check_foundation ( foundation : & Foundation , suit : Suit ) -> Result < ( ) , String > { for ( i , card ) in foundation . iter ( ) . enumerate ( ) { if card . suit != suit { return Err ( format ! ( " " suit card suit card ) ) ; } if card . rank != 1 + i as u8 { return Err ( format ! ( " " suit card rank i 1 ) ) ; } } Ok ( ( ) ) }
Checks whether the cards in a foundation have the required suit and are in the correct order.
Checks whether the cards in a foundation have the required suit and are in the correct order .
foundation
&Foundation
suit
Suit