Skip to content

Commit 6fdb7c4

Browse files
committed
Add missing serde implementations
1 parent a606ad1 commit 6fdb7c4

File tree

15 files changed

+26
-1
lines changed

15 files changed

+26
-1
lines changed

src/grid/small_bit_grid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type GridBits = u64;
88

99
/// A grid with up to 64 tiles holding a single bit of information.
1010
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
11+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1112
pub struct SmallBitGrid<T> {
1213
width: u8,
1314
height: u8,

src/grid/vec_grid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::grid::{FiniteGrid, Grid};
44

55
/// Grid with arbitrary finite size
66
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
7+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
78
pub struct VecGrid<T> {
89
width: u8,
910
height: u8,

src/loopy/impartial/games/wind_up.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{collections::HashSet, fmt::Display};
1111

1212
/// Modular subtraction game
1313
#[derive(Debug, Clone, PartialEq, Eq)]
14+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1415
pub struct WindUp {
1516
graph: Vec<Vertex>,
1617
subtraction_set: Vec<u32>,

src/loopy/impartial/vertex.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::fmt::Display;
55

66
/// Vertex set used during graph orbiting
77
#[derive(Debug, Clone, PartialEq, Eq)]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
89
pub enum UnresolvedVertex {
910
/// Vertex that is equal to some finite nimber or a loop.
1011
Resolved(Vertex),
@@ -15,6 +16,7 @@ pub enum UnresolvedVertex {
1516

1617
/// Value of graph vertex - finite or infinite
1718
#[derive(Debug, Clone, PartialEq, Eq)]
19+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1820
pub enum Vertex {
1921
/// Vertex that is equal to some finite nimber.
2022
Value(Nimber),

src/numeric/nimber.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::fmt::Display;
88
/// Addition is overloaded to Nim sum.
99
#[repr(transparent)]
1010
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
11+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1112
pub struct Nimber(u32);
1213

1314
impl Nimber {

src/short/impartial/games/pseudo_quicksort.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::fmt::Display;
1212

1313
/// See [`pseudo_quickcheck`](self) header
1414
#[derive(Debug, PartialEq, Eq)]
15+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1516
pub struct PseudoQuicksort {
1617
sequence: Vec<u32>,
1718
}

src/short/impartial/games/quicksort.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{display, short::impartial::impartial_game::ImpartialGame};
1212

1313
/// See [quickcheck](self) header
1414
#[derive(Debug, PartialEq, Eq)]
15+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1516
pub struct Quicksort {
1617
sequence: Vec<u32>,
1718
}

src/short/impartial/games/subtraction.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{display, numeric::nimber::Nimber};
66

77
/// Subtraction game played on an arbitrary finite subtraction set
88
#[derive(Clone, Debug)]
9+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
910
pub struct Sub {
1011
// Invariant: sorted
1112
subtraction_set: Vec<u32>,
@@ -48,6 +49,7 @@ impl Sub {
4849

4950
/// Grundy Sequence of [Sub] iterator using Grundy scale method.
5051
#[derive(Debug)]
52+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5153
pub struct GrundySequence {
5254
/// The underlying subtraction game ruleset
5355
game: Sub,

src/short/partizan/canonical_form.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use std::{
2525

2626
/// A number-up-star game position that is a sum of a number, up and, nimber.
2727
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
28+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2829
pub struct Nus {
2930
number: DyadicRationalNumber,
3031
up_multiple: i32,
@@ -320,6 +321,7 @@ impl Display for Nus {
320321

321322
/// Left and Right moves from a given position
322323
#[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd)]
324+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
323325
pub struct Moves {
324326
/// Left player's moves
325327
pub left: Vec<CanonicalForm>,
@@ -796,6 +798,7 @@ impl_from_str_via_nom!(Moves);
796798
/// Note that ordering is defined structurally for the sake of data structures. For proper partial
797799
/// ordering see instance for [`CanonicalForm`].
798800
#[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd, Ord)]
801+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
799802
enum CanonicalFormInner {
800803
/// Number Up Star sum
801804
Nus(Nus),
@@ -804,9 +807,10 @@ enum CanonicalFormInner {
804807
Moves(Moves),
805808
}
806809

810+
/// Canonical game form
807811
#[repr(transparent)]
808812
#[derive(Debug, Hash, Clone, PartialEq, Eq)]
809-
/// Canonical game form
813+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
810814
pub struct CanonicalForm {
811815
inner: CanonicalFormInner,
812816
}

src/short/partizan/games/domineering.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{fmt::Display, str::FromStr};
1414

1515
/// Tile on a Domineering grid
1616
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Tile)]
17+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1718
pub enum Tile {
1819
/// Tile where domino can be placed
1920
#[tile(char('.'), bool(false), default)]
@@ -26,6 +27,7 @@ pub enum Tile {
2627

2728
/// A Domineering position on a rectengular grid.
2829
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
30+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2931
pub struct Domineering<G = SmallBitGrid<Tile>> {
3032
grid: G,
3133
}

src/short/partizan/games/fission.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{
1414

1515
/// Tile in the game of Fission
1616
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Tile)]
17+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1718
pub enum Tile {
1819
/// Empty tile without stones
1920
#[tile(char('.'), default)]
@@ -30,6 +31,7 @@ pub enum Tile {
3031

3132
/// Game of Fission
3233
#[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd, Ord)]
34+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3335
pub struct Fission<G = VecGrid<Tile>> {
3436
grid: G,
3537
}

src/short/partizan/games/ski_jumps.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::{fmt::Display, hash::Hash, str::FromStr};
1919

2020
/// Skier type
2121
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
22+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2223
pub enum Skier {
2324
/// Skier that can jump over skiers below
2425
Jumper,
@@ -28,6 +29,7 @@ pub enum Skier {
2829

2930
/// Ski Jumps game grid tile
3031
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
32+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3133
pub enum Tile {
3234
/// Empty tile, without skiers
3335
Empty,
@@ -71,6 +73,7 @@ impl CharTile for Tile {
7173
// NOTE: Consider caching positions of left and right skiers to avoid quadratic loops
7274
/// Ski Jumps game
7375
#[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd, Ord)]
76+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7477
pub struct SkiJumps<G = VecGrid<Tile>> {
7578
grid: G,
7679
}

src/short/partizan/games/toads_and_frogs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::{
1818

1919
/// Tile on the Toads and Frogs board
2020
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Tile)]
21+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2122
pub enum Tile {
2223
/// Empty tile without any creature
2324
#[tile(default, char('.'))]
@@ -34,6 +35,7 @@ pub enum Tile {
3435

3536
/// Singular row of the Toads and Frogs board
3637
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
38+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3739
pub struct ToadsAndFrogs {
3840
tiles: Vec<Tile>,
3941
}

src/short/partizan/thermograph.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::{cmp::Ordering, fmt::Display, iter::once};
1212

1313
/// See [thermograph](self) header
1414
#[derive(Debug, Hash, Clone, PartialEq, Eq)]
15+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1516
pub struct Thermograph {
1617
pub(crate) left_wall: Trajectory,
1718
pub(crate) right_wall: Trajectory,

src/short/partizan/trajectory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{cmp::Ordering, fmt::Display};
88
/// A continuous piecewise linear trajectory with rational slopes and critical points.
99
/// Each trajectory is defined for all rational numbers on the interval `-1 ≤ x < ∞`.
1010
#[derive(Debug, Hash, Clone, PartialEq, Eq)]
11+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1112
pub struct Trajectory {
1213
/// A `critical point` is a point at which the trajectory changes slope, and must be strictly
1314
/// between `-1` and `∞`.

0 commit comments

Comments
 (0)