standard_card 1.4.0

A Lightweight Library for Efficient Card Representation
Documentation
/// This function takes a deck of cards with up to five cards and generates a unique identifier that is independent of the card order
///
/// # Arguments
/// cards - A deck of cards with up to five cards
///
/// # Returns
/// A unique identifier that is independent of the card order

/// # Example
/// ```
/// use standard_card::card::create;
/// use standard_card::deck::unique5;
///
/// let cards = vec![create(0, 0), create(1, 0), create(2, 0)];
/// let actual = unique5(&cards);
///
/// assert_eq!(actual, 2 * 3 * 5);
/// ```
///
pub fn unique5(cards: &Vec<i32>) -> i32 {
    let mut result: i32 = 1;

    for card in cards {
        result *= card & 0x3f;
    }

    result
}

#[cfg(test)]
mod unique5 {
    use crate::card::create;
    use crate::deck::unique5;

    #[test]
    fn return_true() {
        // Arrange
        let cards = vec![create(0, 0), create(1, 0), create(2, 0)];

        // Act
        let actual = unique5(&cards);

        // Assert
        assert_eq!(actual, 2 * 3 * 5);
    }
}