• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattwparas / steel / 19643200669

24 Nov 2025 05:24PM UTC coverage: 49.283% (-0.03%) from 49.314%
19643200669

Pull #574

github

web-flow
Merge a59c922d4 into ed9e0c34e
Pull Request #574: Add bitwise operators and hash code function

7 of 51 new or added lines in 3 files covered. (13.73%)

18 existing lines in 4 files now uncovered.

15943 of 32350 relevant lines covered (49.28%)

3471394.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.05
/crates/steel-parser/src/span.rs
1
use core::ops::Range;
2
use serde::{Deserialize, Serialize};
3
use std::fmt;
4

5
use super::parser::SourceId;
6

7
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Default)]
8
#[repr(C)]
9
pub struct Span {
10
    pub start: u32,
11
    pub end: u32,
12
    pub source_id: Option<SourceId>,
13
}
14

15
impl Span {
16
    #[inline]
17
    pub const fn new(start: u32, end: u32, source_id: Option<SourceId>) -> Self {
82,643✔
18
        Self {
19
            start,
20
            end,
21
            source_id,
22
        }
23
    }
24

25
    #[inline]
26
    pub const fn double(span: u32, source_id: Option<SourceId>) -> Self {
×
27
        Self {
28
            start: span,
29
            end: span,
30
            source_id,
31
        }
32
    }
33

34
    #[inline]
35
    pub const fn start(&self) -> u32 {
409,502✔
36
        self.start
409,502✔
37
    }
38

39
    #[inline]
40
    pub const fn end(&self) -> u32 {
409,502✔
41
        self.end
409,502✔
42
    }
43

44
    #[inline]
45
    pub const fn range(&self) -> Range<u32> {
×
46
        self.start..self.end
×
47
    }
48

49
    #[inline]
50
    pub const fn usize_range(&self) -> Range<usize> {
×
51
        self.start as _..self.end as _
×
52
    }
53

54
    #[inline]
UNCOV
55
    pub const fn source_id(&self) -> Option<SourceId> {
×
UNCOV
56
        self.source_id
×
57
    }
58

59
    #[inline]
60
    pub const fn merge(start: Self, end: Self) -> Span {
3,999,823✔
61
        // TODO: If this doesn't seem to make sense with macros, we can revisit
62
        Self::new(start.start, end.end, start.source_id)
15,999,292✔
63
    }
64

65
    #[inline]
66
    pub const fn width(&self) -> u32 {
×
67
        self.end - self.start
×
68
    }
69

70
    pub fn coalesce_span(spans: &[Span]) -> Span {
69,586✔
71
        let span = spans.first();
208,758✔
72
        if let Some(span) = span {
139,137✔
73
            let mut span = *span;
139,102✔
74
            for s in spans {
398,059✔
75
                if s.start() < span.start() {
493,443✔
76
                    span = Span::new(s.start(), span.end(), s.source_id);
3,405✔
77
                }
78
                if s.end() > span.end() {
573,075✔
79
                    span = Span::new(span.start(), s.end(), s.source_id);
401,565✔
80
                }
81
            }
82
            span
69,551✔
83
        } else {
84
            Span::new(0, 0, None)
70✔
85
        }
86
    }
87
}
88

89
impl fmt::Debug for Span {
90
    #[inline]
91
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
92
        write!(f, "{}..{}", self.start, self.end)
×
93
    }
94
}
95

96
impl From<Span> for Range<u32> {
97
    fn from(span: Span) -> Self {
×
98
        span.start..span.end
×
99
    }
100
}
101

102
impl From<Span> for Range<usize> {
103
    fn from(span: Span) -> Self {
49✔
104
        span.start as usize..span.end as usize
49✔
105
    }
106
}
107

108
impl From<Span> for (u32, u32) {
109
    fn from(span: Span) -> Self {
×
110
        (span.start, span.end)
×
111
    }
112
}
113

114
impl From<Span> for [u32; 2] {
115
    fn from(span: Span) -> Self {
×
116
        [span.start, span.end]
×
117
    }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc