Give the Card an associated fn new()
So that we don't have to keep doing the `{ cells: ... ..default() }`
thing.
This commit is contained in:
15
src/card.rs
15
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<Self>) {
|
||||
let mut new_card = Self::default();
|
||||
|
||||
Reference in New Issue
Block a user