card: new -> make_joker and make_playing-card
Always better to be explicit with our constructor names.
This commit is contained in:
@@ -55,7 +55,11 @@ impl PlayingCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Card {
|
impl Card {
|
||||||
pub fn new(rank: Rank, suit: Suit) -> Self {
|
pub fn make_joker() -> Self {
|
||||||
|
Self::Joker(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn make_playing_card(rank: Rank, suit: Suit) -> Self {
|
||||||
Self::PlayingCard(PlayingCard::new(0, rank, suit))
|
Self::PlayingCard(PlayingCard::new(0, rank, suit))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn new() {
|
fn new() {
|
||||||
// Two jokers can never be a pair.
|
// Two jokers can never be a pair.
|
||||||
assert_eq!(Pair::new(Card::joker(), Card::joker()), None);
|
assert_eq!(Pair::new(Card::make_joker(), Card::make_joker()), None);
|
||||||
|
|
||||||
for rank in 0..13 {
|
for rank in 0..13 {
|
||||||
// Vector of cards of a rank: size 4.
|
// Vector of cards of a rank: size 4.
|
||||||
@@ -157,7 +157,7 @@ mod tests {
|
|||||||
|
|
||||||
// TEST: Pairs may have one joker.
|
// TEST: Pairs may have one joker.
|
||||||
let pair = {
|
let pair = {
|
||||||
let p = Pair::new(c1, Card::joker());
|
let p = Pair::new(c1, Card::make_joker());
|
||||||
assert_ne!(p, None);
|
assert_ne!(p, None);
|
||||||
p.unwrap()
|
p.unwrap()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn new() {
|
fn new() {
|
||||||
// TEST: Jokers are not valid singles.
|
// TEST: Jokers are not valid singles.
|
||||||
assert!(Single::new(Card::joker()).is_none());
|
assert!(Single::new(Card::make_joker()).is_none());
|
||||||
|
|
||||||
let deck = make_decks(1);
|
let deck = make_decks(1);
|
||||||
let singles: Vec<Option<Single>> =
|
let singles: Vec<Option<Single>> =
|
||||||
|
|||||||
Reference in New Issue
Block a user