pub struct ManualClock(/* private fields */);Expand description
Time that moves only when the test says so: advance runs the jobs that
became due, in order, on the caller’s thread. Clones are the same clock.
use serialplugin_testing::{Clock, ManualClock};
use std::sync::{Arc, Mutex};
use std::time::Duration;
let clock = ManualClock::new();
let fired = Arc::new(Mutex::new(Vec::new()));
let f = fired.clone();
clock.at(Duration::from_secs(2), Box::new(move || f.lock().unwrap().push(2)));
clock.advance(Duration::from_secs(1));
assert!(fired.lock().unwrap().is_empty());
clock.advance(Duration::from_secs(1));
assert_eq!(*fired.lock().unwrap(), [2]);Implementations§
Source§impl ManualClock
impl ManualClock
Trait Implementations§
Auto Trait Implementations§
impl Forget for ManualClock
impl Freeze for ManualClock
impl Move for ManualClock
impl RefUnwindSafe for ManualClock
impl Send for ManualClock
impl Sync for ManualClock
impl Unpin for ManualClock
impl UnsafeUnpin for ManualClock
impl UnwindSafe for ManualClock
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