pub struct Clock { /* private fields */ }Expand description
A monotonic clock, either the real one or a paused one that a test advances by hand.
Clones share one clock. Equality is identity, not the current time, so all real clocks are equal and a paused clock equals only its own clones.
Implementations§
Source§impl Clock
impl Clock
Sourcepub fn paused() -> Self
Available on crate feature test-clock only.
pub fn paused() -> Self
test-clock only.Creates a paused clock, set to the current real time. It moves only
when Clock::advance or Clock::advance_to moves it.
Sourcepub fn advance_to(&self, target: Instant)
Available on crate feature test-clock only.
pub fn advance_to(&self, target: Instant)
test-clock only.Moves a paused clock forward to target and wakes all its waiters. It
returns once they are notified, without waiting for them to act.
Advancing to the current time does nothing.
§Panics
Panics on a real clock, or if target is earlier than the current time.
The time is unchanged after a panic.
Trait Implementations§
impl Eq for Clock
Available on crate features
test-clock only.Auto Trait Implementations§
impl Freeze for Clock
impl RefUnwindSafe for Clock
impl Send for Clock
impl Sync for Clock
impl Unpin for Clock
impl UnsafeUnpin for Clock
impl UnwindSafe for Clock
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