Cards(Vec::new())
}
- pub fn into_inner(self) -> Vec<u32> {
- self.0.into_iter().map(|c| c.into_inner()).collect()
+ pub fn into_inner(self) -> Vec<Card> {
+ self.0
}
- pub fn as_vec_card(&self) -> &Vec<Card> {
- &self.0
+ pub fn push(&mut self, value: Card) {
+ self.0.push(value)
+ }
+
+ pub fn is_empty(&self) -> bool {
+ self.0.is_empty()
+ }
+
+ pub fn len(&self) -> usize {
+ self.0.len()
}
}
{
let mut cards = Cards::new();
for i in iter {
- cards.0.push(i)
+ cards.push(i)
}
cards
}
}
+impl FromIterator<Card> for Vec<u32> {
+ fn from_iter<T>(iter: T) -> Self
+ where
+ T: IntoIterator<Item = Card>,
+ {
+ let mut v = Vec::new();
+ for i in iter {
+ v.push(i.0)
+ }
+ v
+ }
+}
+
+impl IntoIterator for Cards {
+ type Item = Card;
+
+ type IntoIter = std::vec::IntoIter<Self::Item>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.0.into_iter()
+ }
+}
+
+impl AsRef<Vec<Card>> for Cards {
+ fn as_ref(&self) -> &Vec<Card> {
+ &self.0
+ }
+}
+
impl Extend<Card> for Cards {
fn extend<T>(&mut self, iter: T)
where
impl From<Cards> for Vec<u32> {
fn from(c: Cards) -> Self {
- Vec::from(c.into_inner())
+ c.into_iter().map(|card| card.into_inner()).collect()
}
}
}
}
+impl AsRef<Card> for Card {
+ fn as_ref(&self) -> &Card {
+ self
+ }
+}
+
impl TryFrom<u32> for Card {
type Error = ParseCardError;