feat: add From<Cards> for Vec<u32> and transparent repr for Card
authorMA Beaudet <ma@beaudet.xyz>
Sun, 7 Nov 2021 19:45:12 +0000 (20:45 +0100)
committerMA Beaudet <ma@beaudet.xyz>
Sun, 7 Nov 2021 19:45:12 +0000 (20:45 +0100)
src/lib.rs

index e173037..c5e5543 100644 (file)
@@ -260,6 +260,12 @@ impl std::fmt::Display for Cards {
     }
 }
 
+impl From<Cards> for Vec<u32> {
+    fn from(c: Cards) -> Self {
+        c.0.into_iter().map(|c| u32::from(c)).collect()
+    }
+}
+
 /// ```
 /// use poker_eval::{Card};
 /// use std::str::FromStr;
@@ -268,6 +274,7 @@ impl std::fmt::Display for Cards {
 ///     Card::from_str("Kd").unwrap().get(),
 ///     0b00001000_00000000_01001011_00100101_u32
 /// );
+#[repr(transparent)]
 #[derive(Debug, Clone, Copy)]
 pub struct Card(u32);