From c0ed58e89097ce6e6d41e034b1b060c95ea41e78 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Wed, 27 Aug 2025 12:49:55 -0500 Subject: [PATCH] Give the Card an associated `fn new()` So that we don't have to keep doing the `{ cells: ... ..default() }` thing. --- src/card.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/card.rs b/src/card.rs index 048a87d..6c9cecf 100644 --- a/src/card.rs +++ b/src/card.rs @@ -82,6 +82,21 @@ pub struct Card { } impl Card { + /// Create a new card from the given Cell array + pub const fn new(cells: [Cell; 9]) -> Self { + Self { + cells, + nw: false, + n: false, + ne: false, + w: false, + e: false, + sw: false, + s: false, + se: false, + } + } + /// Produces a new card by stacking another on top of this one. pub fn merge(self, top: Self) -> (Self, Option) { let mut new_card = Self::default();