Implement custom Debug for Time
This commit is contained in:
parent
6d090b428f
commit
7c5bd26049
1 changed files with 7 additions and 1 deletions
|
|
@ -43,12 +43,18 @@ impl<T> Spanned<T> {
|
|||
// }
|
||||
// }
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Time {
|
||||
pub hour: u8,
|
||||
pub min: u8,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Time {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:02}:{:02}", self.hour, self.min)
|
||||
}
|
||||
}
|
||||
|
||||
impl Time {
|
||||
pub fn new(hour: u32, min: u32) -> Option<Self> {
|
||||
if hour < 24 && min < 60 || hour == 24 && min == 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue