Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Commit

Permalink
impl Display and Debug and Deref for GameClock
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed Sep 20, 2023
1 parent 1f0181c commit dbd339c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/game_clock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::*;
use bevy::prelude::*;
use std::fmt;
use std::ops::Deref;

#[derive(Resource, Default)]
pub struct GameClock {
Expand All @@ -25,3 +27,22 @@ impl GameClock {
self.frame = frame;
}
}

impl Deref for GameClock {
type Target = FrameNumber;
fn deref(&self) -> &Self::Target {
&self.frame
}
}

impl fmt::Debug for GameClock {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[[f={}]]", self.frame)
}
}

impl fmt::Display for GameClock {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[f={}]", self.frame)
}
}

0 comments on commit dbd339c

Please sign in to comment.