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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Positions in an arena: spans of expansions and marks of the top.
use Range;
/// The position of an expansion in a [`Scratch`](super::Scratch) arena.
///
/// Spans compare equal, and hash alike, when they have the same position and
/// length, whatever their contents. A span is meaningful only for the arena that created it;
/// see the [module documentation](crate::scratch).
///
/// # Examples
///
/// ```
/// use implicit_predicates_core::Scratch;
///
/// let mut buf = [0.0; 4];
/// let mut scratch = Scratch::borrowed(&mut buf);
/// let span = scratch.push(&[1e-20, 1.0])?;
/// assert_eq!(span.len(), 2);
/// assert_eq!(scratch.get(span), &[1e-20, 1.0]);
/// # Ok::<(), implicit_predicates_core::ScratchExhausted>(())
/// ```
/// A saved top of a [`Scratch`](super::Scratch) arena, to return to with
/// [`Scratch::reset`](super::Scratch::reset). Marks compare equal when they
/// save the same top.
///
/// # Examples
///
/// ```
/// use implicit_predicates_core::Scratch;
///
/// let mut buf = [0.0; 4];
/// let mut scratch = Scratch::borrowed(&mut buf);
/// let mark = scratch.mark();
/// scratch.push(&[1.0])?;
/// assert_ne!(scratch.mark(), mark);
/// scratch.reset(mark);
/// assert_eq!(scratch.mark(), mark);
/// assert_eq!(scratch.used(), 0);
/// # Ok::<(), implicit_predicates_core::ScratchExhausted>(())
/// ```
u32);
/// Converts an index within the arena, which never exceeds the length of
/// its buffer, to `usize`.
pub