1#[derive(Debug, Clone, Eq, Hash, PartialEq)]
2pub struct CodeRange {
3 pub start: u32,
5
6 pub end: u32,
8
9 pub address: usize,
13}
14
15impl CodeRange {
16 pub fn new(start: u32, end: u32, src: &str) -> Self {
17 let raw_ptr = src as *const str;
18 let thin_ptr = raw_ptr as *const u8;
19 let address = thin_ptr as usize;
20 Self {
21 start,
22 end,
23 address,
24 }
25 }
26
27 pub fn applies_to(&self, source: &str) -> bool {
29 let raw_ptr = source as *const str;
30 let thin_ptr = raw_ptr as *const u8;
31 let address = thin_ptr as usize;
32 self.address == address
33 }
34
35 pub fn contains(&self, index: u32) -> bool {
37 self.start <= index && self.end > index
38 }
39}