1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! The one verb every clock answers.
/// A clock: what time it is now.
///
/// The type a clock reads says which timeline its readings are on, so readings of two timelines
/// never mix: a point for a clock that names a moment, and a span for one that counts CPU time.
///
/// # Examples
/// ```
/// use core::cell::Cell;
///
/// use t2t_clock::Clock;
/// use t2t_core::Tickstamp;
///
/// /// A clock that moves one tick at each reading.
/// struct StepClock(Cell<i64>);
///
/// impl Clock for StepClock {
/// type Reading = Tickstamp;
///
/// fn now(&self) -> Tickstamp {
/// self.0.set(self.0.get() + 1);
/// Tickstamp::from_ticks(self.0.get())
/// }
/// }
///
/// let clock = StepClock(Cell::new(0));
/// assert!(clock.now() < clock.now(), "each reading later than the last");
/// ```