From: MA Beaudet Date: Sun, 7 Nov 2021 19:45:12 +0000 (+0100) Subject: feat: add From for Vec and transparent repr for Card X-Git-Url: https://git.beaudet.xyz/?a=commitdiff_plain;h=725b8da869194272270db9d089931a553f0d7d42;p=poker-eval.git feat: add From for Vec and transparent repr for Card --- diff --git a/src/lib.rs b/src/lib.rs index e173037..c5e5543 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -260,6 +260,12 @@ impl std::fmt::Display for Cards { } } +impl From for Vec { + 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);