Coverage Report

Created: 2026-09-28 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/indexmap-2.5.0/src/util.rs
Line
Count
Source
1
use core::ops::{Bound, Range, RangeBounds};
2
3
0
pub(crate) fn third<A, B, C>(t: (A, B, C)) -> C {
4
0
    t.2
5
0
}
Unexecuted instantiation: indexmap::util::third::<usize, alloc::string::String, indexmap::map::IndexMap<alloc::string::String, core::option::Option<alloc::string::String>>>
Unexecuted instantiation: indexmap::util::third::<usize, alloc::string::String, core::option::Option<alloc::string::String>>
Unexecuted instantiation: indexmap::util::third::<_, _, _>
6
7
0
pub(crate) fn simplify_range<R>(range: R, len: usize) -> Range<usize>
8
0
where
9
0
    R: RangeBounds<usize>,
10
{
11
0
    let start = match range.start_bound() {
12
0
        Bound::Unbounded => 0,
13
0
        Bound::Included(&i) if i <= len => i,
14
0
        Bound::Excluded(&i) if i < len => i + 1,
15
0
        bound => panic!("range start {:?} should be <= length {}", bound, len),
16
    };
17
0
    let end = match range.end_bound() {
18
0
        Bound::Unbounded => len,
19
0
        Bound::Excluded(&i) if i <= len => i,
20
0
        Bound::Included(&i) if i < len => i + 1,
21
0
        bound => panic!("range end {:?} should be <= length {}", bound, len),
22
    };
23
0
    if start > end {
24
0
        panic!(
25
0
            "range start {:?} should be <= range end {:?}",
26
0
            range.start_bound(),
27
0
            range.end_bound()
28
        );
29
0
    }
30
0
    start..end
31
0
}
32
33
0
pub(crate) fn try_simplify_range<R>(range: R, len: usize) -> Option<Range<usize>>
34
0
where
35
0
    R: RangeBounds<usize>,
36
{
37
0
    let start = match range.start_bound() {
38
0
        Bound::Unbounded => 0,
39
0
        Bound::Included(&i) if i <= len => i,
40
0
        Bound::Excluded(&i) if i < len => i + 1,
41
0
        _ => return None,
42
    };
43
0
    let end = match range.end_bound() {
44
0
        Bound::Unbounded => len,
45
0
        Bound::Excluded(&i) if i <= len => i,
46
0
        Bound::Included(&i) if i < len => i + 1,
47
0
        _ => return None,
48
    };
49
0
    if start > end {
50
0
        return None;
51
0
    }
52
0
    Some(start..end)
53
0
}