summaryrefslogtreecommitdiff
path: root/dhall/src/expr.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-11 16:41:06 +0200
committerNadrieril2019-04-11 19:21:03 +0200
commitd17d553a39aa3bffdfc19b7fe4801b85d6bd80f7 (patch)
treeb04c707f865b98889414022f8aa639b1f541f671 /dhall/src/expr.rs
parent7ba857a96eebbdd1cef0aa22407c870887d24aed (diff)
Add lifetime parameters to Parsed and Resolved
Future-proofing
Diffstat (limited to 'dhall/src/expr.rs')
-rw-r--r--dhall/src/expr.rs35
1 files changed, 31 insertions, 4 deletions
diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs
index 1ce20e3..e3a2fe5 100644
--- a/dhall/src/expr.rs
+++ b/dhall/src/expr.rs
@@ -1,5 +1,6 @@
use crate::imports::ImportRoot;
use dhall_core::*;
+use std::marker::PhantomData;
macro_rules! derive_other_traits {
($ty:ident) => {
@@ -20,13 +21,39 @@ macro_rules! derive_other_traits {
};
}
+macro_rules! derive_other_traits_ {
+ ($ty:ident) => {
+ impl<'a> std::cmp::PartialEq for $ty<'a> {
+ fn eq(&self, other: &Self) -> bool {
+ self.0 == other.0
+ }
+ }
+
+ impl<'a> std::fmt::Display for $ty<'a> {
+ fn fmt(
+ &self,
+ f: &mut std::fmt::Formatter,
+ ) -> Result<(), std::fmt::Error> {
+ self.0.fmt(f)
+ }
+ }
+ };
+}
+
#[derive(Debug, Clone, Eq)]
-pub struct Parsed(pub(crate) SubExpr<X, Import>, pub(crate) ImportRoot);
-derive_other_traits!(Parsed);
+pub struct Parsed<'a>(
+ pub(crate) SubExpr<X, Import>,
+ pub(crate) ImportRoot,
+ pub(crate) PhantomData<&'a ()>,
+);
+derive_other_traits_!(Parsed);
#[derive(Debug, Clone, Eq)]
-pub struct Resolved(pub(crate) SubExpr<X, Normalized>);
-derive_other_traits!(Resolved);
+pub struct Resolved<'a>(
+ pub(crate) SubExpr<X, Normalized>,
+ pub(crate) PhantomData<&'a ()>,
+);
+derive_other_traits_!(Resolved);
#[derive(Debug, Clone, Eq)]
pub struct Typed(pub(crate) SubExpr<X, Normalized>, pub(crate) Option<Type>);