Skip to content

Commit 4a2ebe1

Browse files
committed
player: doc
1 parent c2fb3e5 commit 4a2ebe1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/player.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ impl Display for Player {
7070
}
7171

7272
impl Player {
73+
/// Used by the caller / game logic to take a Player's cards (ostensibly after the Player has
74+
/// played them legally).
7375
pub fn remove_hand_from_cards(&mut self, hand: &Hand) {
7476
assert!(self.has_cards(hand));
7577
match hand {
@@ -80,6 +82,9 @@ impl Player {
8082
}
8183
}
8284

85+
/// Used internally to remove any slice of cards from a Player's cards.
86+
/// # Panics
87+
/// - Will panic if any of cards_to_remove are not in Player's cards.
8388
fn remove_cards_from_cards(&mut self, cards_to_remove: &[Card]) {
8489
for to_remove in cards_to_remove {
8590
let index = self
@@ -91,11 +96,14 @@ impl Player {
9196
}
9297
}
9398

99+
/// Used to make sure the Player actually has the cards they tried to play.
94100
pub fn has_cards(&self, hand: &Hand) -> bool {
95101
Player::hand_in_cards(hand, &self.cards)
96102
}
97103

98-
pub fn hand_in_cards(hand: &Hand, cards: &[Card]) -> bool {
104+
/// Used internally, converts players cards into BTreeSet to check if cards from hand are
105+
/// present.
106+
fn hand_in_cards(hand: &Hand, cards: &[Card]) -> bool {
99107
let cards: BTreeSet<&Card> = BTreeSet::from_iter(cards);
100108
match hand {
101109
Hand::Lone(a) => cards.contains(a),

0 commit comments

Comments
 (0)