4 Commits

Author SHA1 Message Date
Quaternions 6f42e7d2bb clippy fixes 2026-06-10 20:43:43 -07:00
Quaternions a8106ad0b5 iterators for Tableau and Foundation 2026-06-10 20:43:43 -07:00
Quaternions fb01881f62 klondike v0.4.0 tweaks + serde 2026-06-09 10:18:50 -07:00
Quaternions dba77e7c74 card_game v0.4.1 serde 2026-06-09 10:17:51 -07:00
5 changed files with 70 additions and 6 deletions
Generated
+2 -2
View File
@@ -28,7 +28,7 @@ checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
[[package]]
name = "card_game"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"arrayvec",
"serde",
@@ -179,7 +179,7 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "klondike"
version = "0.3.0"
version = "0.4.0"
dependencies = [
"card_game",
"insta",
+2 -2
View File
@@ -8,8 +8,8 @@ members = [
resolver = "3"
[workspace.dependencies]
card_game = { version = "0.4.0", path = "card_game", registry = "Quaternions" }
klondike = { version = "0.3.0", path = "klondike", registry = "Quaternions" }
card_game = { version = "0.4.1", path = "card_game", registry = "Quaternions" }
klondike = { version = "0.4.0", path = "klondike", registry = "Quaternions" }
[workspace.lints.rust]
# unsafe_code = "forbid"
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "card_game"
version = "0.4.0"
version = "0.4.1"
edition = "2024"
repository = "https://git.aleshym.co/Quaternions/card_game"
license = "MIT OR Apache-2.0"
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "klondike"
version = "0.3.0"
version = "0.4.0"
edition = "2024"
[dependencies]
+64
View File
@@ -164,6 +164,38 @@ impl Tableau {
})
}
}
pub struct TableauIter {
tableau: Option<Tableau>,
}
impl TableauIter {
pub const fn new() -> Self {
Self {
tableau: Some(Tableau::ITER_BEGIN),
}
}
}
impl Default for TableauIter {
fn default() -> Self {
Self::new()
}
}
impl Iterator for TableauIter {
type Item = Tableau;
fn next(&mut self) -> Option<Self::Item> {
let tableau = self.tableau?;
self.tableau = tableau.next();
Some(tableau)
}
}
impl IntoIterator for Tableau {
type Item = Self;
type IntoIter = TableauIter;
fn into_iter(self) -> Self::IntoIter {
TableauIter {
tableau: Some(self),
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum Foundation {
@@ -184,6 +216,38 @@ impl Foundation {
})
}
}
pub struct FoundationIter {
foundation: Option<Foundation>,
}
impl FoundationIter {
pub const fn new() -> Self {
Self {
foundation: Some(Foundation::ITER_BEGIN),
}
}
}
impl Default for FoundationIter {
fn default() -> Self {
Self::new()
}
}
impl Iterator for FoundationIter {
type Item = Foundation;
fn next(&mut self) -> Option<Self::Item> {
let foundation = self.foundation?;
self.foundation = foundation.next();
Some(foundation)
}
}
impl IntoIterator for Foundation {
type Item = Self;
type IntoIter = FoundationIter;
fn into_iter(self) -> Self::IntoIter {
FoundationIter {
foundation: Some(self),
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum KlondikePile {