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
/// A range of byte indices in a source file.
pub type Span = Range;
/// Combines two spans into one span.
///
/// The resulting span will contain all indices in the original spans, possibly with some additional
/// indices included between them.
///
/// # Examples
///
/// ```
/// # use rich_err::span::combine_spans;
/// assert_eq!(combine_spans([69..420, 42..100]), 42..420);
/// assert_eq!(combine_spans([21..32, 27..84]), 21..84);
/// assert_eq!(combine_spans([0..100, 300..500]), 0..500);
/// assert_eq!(combine_spans([0..100, 10..20]), 0..100);
/// ```
pub const
/// Combines the consumed span with the consumer.
///
/// The consumer will then contain all the indices it used to along with all those in the consumed
/// span (possibly plus some extras to make it one continuous span).
///
/// # Examples
///
/// ```
/// # use rich_err::span::consume_span;
/// let mut total_span = 69..420;
/// consume_span(&mut total_span, 42..100);
/// assert_eq!(total_span, 42..420);
/// consume_span(&mut total_span, 420..696);
/// assert_eq!(total_span, 42..696);
/// consume_span(&mut total_span, 700..1000);
/// assert_eq!(total_span, 42..1000);
/// consume_span(&mut total_span, 100..200); // This shouldn't do anything.
/// assert_eq!(total_span, 42..1000);
/// ```
pub const
/// Returns the minimum of two [`usize`]s.
///
/// This is a `const` alternative to [`usize::min`].
const
/// Returns the maximum of two [`usize`]s.
///
/// This is a `const` alternative to [`usize::max`].
const