impl Debug for CardSet
authorGeoffrey Allott <geoffrey@allott.email>
Mon, 5 Jun 2023 20:21:44 +0000 (21:21 +0100)
committerGeoffrey Allott <geoffrey@allott.email>
Mon, 5 Jun 2023 20:21:44 +0000 (21:21 +0100)
src/card.rs

index 1c6940fad3340012884b775410c7d31e6edddf70..7391a7380cf279872aaaf47976cda61b9e6e61d2 100644 (file)
@@ -1,4 +1,6 @@
-use std::fmt::{self, Display, Formatter};
+use std::fmt::{self, Debug, Display, Formatter};
+
+use itertools;
 
 use self::Rank::*;
 use self::Suit::*;
@@ -125,18 +127,26 @@ impl Display for Card {
     }
 }
 
-#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
+#[derive(Copy, Clone, Default, PartialEq, Eq, Hash)]
 pub struct CardSet {
     repr: u64,
 }
 
+impl Debug for CardSet {
+    fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
+        fmt.debug_struct("CardSet")
+            .field("repr", &format_args!("{:#015x} /*{}*/", self.repr, itertools::join(*self, ", ")))
+            .finish()
+    }
+}
+
 impl CardSet {
     pub fn new() -> CardSet {
         CardSet { repr: 0 }
     }
 
     pub fn fifty_two_card_deck() -> CardSet {
-        CardSet { repr: 0b1111111111111_1111111111111_1111111111111_1111111111111 }
+        CardSet { repr: 0xfffffffffffff }
     }
 
     pub fn is_empty(&self) -> bool {