pedant_core/resolution/rust/snapshot/
source.rs1use std::sync::Arc;
4
5use crate::ir::FileIr;
6
7#[derive(Debug)]
9pub struct RustSource {
10 pub(super) path: Arc<str>,
11 pub(super) text: Arc<str>,
12 pub(super) digest: [u8; 32],
13 pub(super) ir: FileIr,
14}
15
16impl RustSource {
17 pub fn path(&self) -> &str {
19 &self.path
20 }
21
22 pub(in crate::resolution::rust) fn shared_path(&self) -> &Arc<str> {
24 &self.path
25 }
26
27 pub fn text(&self) -> &str {
29 &self.text
30 }
31
32 pub fn digest(&self) -> &[u8; 32] {
34 &self.digest
35 }
36
37 pub fn ir(&self) -> &FileIr {
39 &self.ir
40 }
41}
42
43pub(super) fn find<'a>(sources: &'a [RustSource], path: &str) -> Option<&'a RustSource> {
45 sources
46 .binary_search_by(|source| (*source.path).cmp(path))
47 .ok()
48 .and_then(|index| sources.get(index))
49}