Skip to content

Commit

Permalink
feat(Instant): Impl Hash
Browse files Browse the repository at this point in the history
  • Loading branch information
PTaylor-us committed Aug 6, 2020
1 parent 3d76d49 commit 04602d7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ use crate::{
duration::{self, Duration},
fixed_point::FixedPoint,
};
use core::{cmp::Ordering, convert::TryFrom, ops};
use core::{
cmp::Ordering,
convert::TryFrom,
hash::{Hash, Hasher},
ops,
};
use num::traits::{WrappingAdd, WrappingSub};

/// Represents an instant of time relative to a specific [`Clock`](clock/trait.Clock.html)
Expand Down Expand Up @@ -372,5 +377,12 @@ where
}
}

impl<Clock: crate::clock::Clock> Hash for Instant<Clock> {
fn hash<H: Hasher>(&self, state: &mut H) {
Clock::SCALING_FACTOR.hash(state);
self.ticks.hash(state);
}
}

#[cfg(test)]
mod tests {}

0 comments on commit 04602d7

Please sign in to comment.