Initial implementation of policy coverage (#146)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-02-18 22:16:53 -08:00
committed by GitHub
parent bdb2aba596
commit f3d9652a73
12 changed files with 451 additions and 19 deletions
+33
View File
@@ -6,6 +6,7 @@ use core::iter::Peekable;
use core::str::CharIndices;
use std::convert::AsRef;
use std::hash::{Hash, Hasher};
use std::path::Path;
use crate::Rc;
@@ -25,6 +26,38 @@ pub struct Source {
src: Rc<SourceInternal>,
}
impl std::cmp::Ord for Source {
fn cmp(&self, other: &Source) -> std::cmp::Ordering {
Rc::as_ptr(&self.src).cmp(&Rc::as_ptr(&other.src))
}
}
impl std::cmp::PartialOrd for Source {
fn partial_cmp(&self, other: &Source) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl std::cmp::PartialEq for Source {
fn eq(&self, other: &Source) -> bool {
Rc::as_ptr(&self.src) == Rc::as_ptr(&other.src)
}
}
impl std::cmp::Eq for Source {}
impl Hash for Source {
fn hash<H: Hasher>(&self, state: &mut H) {
Rc::as_ptr(&self.src).hash(state)
}
}
impl Debug for Source {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
self.src.file.fmt(f)
}
}
#[derive(Clone)]
pub struct SourceStr {
source: Source,