Skip to content

Commit

Permalink
Implement Debug for GameStateCell
Browse files Browse the repository at this point in the history
Easily printing a cell's frame and checksum can be very useful when
debugging.
  • Loading branch information
johanhelsing committed Oct 23, 2023
1 parent 5c6a0e0 commit 8ae279d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/sync_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ impl<T: Clone> Clone for GameStateCell<T> {
}
}

impl<T: Clone> std::fmt::Debug for GameStateCell<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let inner = self.0.lock();
f.debug_struct("GameStateCell")
.field("frame", &inner.frame)
.field("checksum", &inner.checksum)
.finish_non_exhaustive()
}
}

#[derive(Clone)]
pub(crate) struct SavedStates<T: Clone> {
pub states: Vec<GameStateCell<T>>,
Expand Down

0 comments on commit 8ae279d

Please sign in to comment.