pub struct FakeClock { /* private fields */ }Expand description
A fake clock for testing time-dependent code
Allows manual control of time progression, enabling fast and
deterministic tests for Debouncer, Throttler, etc.
§Example
ⓘ
use egui_cha::testing::FakeClock;
use egui_cha::helpers::Debouncer;
use std::time::Duration;
let clock = FakeClock::new();
let mut debouncer = Debouncer::with_clock(clock.clone());
debouncer.trigger(Duration::from_millis(500), Msg::Search);
// Time hasn't passed yet
assert!(!debouncer.should_fire());
// Advance time past the debounce delay
clock.advance(Duration::from_millis(600));
assert!(debouncer.should_fire());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FakeClock
impl !RefUnwindSafe for FakeClock
impl !Send for FakeClock
impl !Sync for FakeClock
impl Unpin for FakeClock
impl UnsafeUnpin for FakeClock
impl !UnwindSafe for FakeClock
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