pub struct ManualClock { /* private fields */ }Expand description
Implementations§
Source§impl ManualClock
impl ManualClock
Sourcepub const fn new(start: u64) -> Self
pub const fn new(start: u64) -> Self
Creates a clock reading start.
Examples found in repository?
examples/basic.rs (line 11)
9fn main() {
10 // Deterministic clock for tests / demos.
11 let clock = ManualClock::new(0);
12 println!("manual t = {}", clock.now());
13 clock.advance(1_000);
14 println!("after advance(1000): t = {}", clock.now());
15
16 // Real monotonic clock (milliseconds since creation).
17 let real = MonotonicClock::new();
18 let a = real.now();
19 let b = real.now();
20 println!("monotonic: {a} -> {b} (non-decreasing: {})", b >= a);
21
22 // Any &Clock works wherever a Clock is expected.
23 println!("via trait object: {}", read(&clock));
24}Sourcepub fn advance(&self, delta: u64)
pub fn advance(&self, delta: u64)
Advances the clock by delta (saturating).
Examples found in repository?
examples/basic.rs (line 13)
9fn main() {
10 // Deterministic clock for tests / demos.
11 let clock = ManualClock::new(0);
12 println!("manual t = {}", clock.now());
13 clock.advance(1_000);
14 println!("after advance(1000): t = {}", clock.now());
15
16 // Real monotonic clock (milliseconds since creation).
17 let real = MonotonicClock::new();
18 let a = real.now();
19 let b = real.now();
20 println!("monotonic: {a} -> {b} (non-decreasing: {})", b >= a);
21
22 // Any &Clock works wherever a Clock is expected.
23 println!("via trait object: {}", read(&clock));
24}Trait Implementations§
Source§impl Debug for ManualClock
impl Debug for ManualClock
Source§impl Default for ManualClock
impl Default for ManualClock
Source§fn default() -> ManualClock
fn default() -> ManualClock
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ManualClock
impl !RefUnwindSafe for ManualClock
impl !Sync for ManualClock
impl Send 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