pub struct MockClock { /* private fields */ }Expand description
Mock clock for testing with interior mutability.
Uses AtomicU64 so the clock can be modified while the generator
holds a reference to it.
§Examples
use nulid::generator::{MockClock, Clock};
use core::time::Duration;
let clock = MockClock::new(1_000_000_000);
assert_eq!(clock.get(), 1_000_000_000);
clock.advance(Duration::from_millis(100));
assert_eq!(clock.get(), 1_100_000_000);
clock.regress(Duration::from_millis(50));
assert_eq!(clock.get(), 1_050_000_000);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MockClock
impl RefUnwindSafe for MockClock
impl Send for MockClock
impl Sync for MockClock
impl Unpin for MockClock
impl UnwindSafe for MockClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more