blob: 049c8f8449770c665bc08a57b8f26d23de457a9a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
use crate::*;
#[derive(Clone)]
pub struct Tracked<T> {
pub source: SourceSpan,
pub value: T,
}
impl<T> Tracked<T> {
pub fn from(value: T, source: &SourceSpan) -> Self {
Self { source: source.clone(), value }
}
}
impl<T> std::ops::Deref for Tracked<T> {
type Target = T;
fn deref(&self) -> &T {
&self.value
}
}
impl<T> std::ops::DerefMut for Tracked<T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.value
}
}
impl<T: std::fmt::Display> std::fmt::Display for Tracked<T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "{}", self.value)
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for Tracked<T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "{:?}", self.value)
}
}
impl<T: PartialEq> PartialEq for Tracked<T> {
fn eq(&self, other: &Tracked<T>) -> bool {
self.value.eq(&other.value)
}
}
impl<T: Eq> Eq for Tracked<T> {}
|