From 250525a05e1af17bb46ceb72879f471e54fb5091 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 2 Sep 2019 23:07:12 +0200 Subject: No need to change the type of Embed when resolving anymore --- dhall_syntax/src/core/expr.rs | 25 ++++++++++++++++--------- dhall_syntax/src/core/visitor.rs | 11 ++++++----- 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index eeee4d8..f46cafb 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -313,21 +313,25 @@ impl ExprF { } impl RawExpr { - pub fn traverse_resolve( + pub fn traverse_resolve( &self, - visit_import: impl FnMut(&Import>) -> Result, - ) -> Result, Err> { + visit_import: impl FnMut(&Import>) -> Result, + ) -> Result, Err> + where + E: Clone, + { self.traverse_resolve_with_visitor(&mut visitor::ResolveVisitor( visit_import, )) } - pub(crate) fn traverse_resolve_with_visitor( + pub(crate) fn traverse_resolve_with_visitor( &self, visitor: &mut visitor::ResolveVisitor, - ) -> Result, Err> + ) -> Result, Err> where - F1: FnMut(&Import>) -> Result, + E: Clone, + F1: FnMut(&Import>) -> Result, { match self { ExprF::BinOp(BinOp::ImportAlt, l, r) => l @@ -368,10 +372,13 @@ impl Expr { } impl Expr { - pub fn traverse_resolve( + pub fn traverse_resolve( &self, - visit_import: impl FnMut(&Import>) -> Result, - ) -> Result, Err> { + visit_import: impl FnMut(&Import>) -> Result, + ) -> Result, Err> + where + E: Clone, + { Ok(self.rewrap(self.as_ref().traverse_resolve(visit_import)?)) } } diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs index 435771e..addb282 100644 --- a/dhall_syntax/src/core/visitor.rs +++ b/dhall_syntax/src/core/visitor.rs @@ -250,24 +250,25 @@ where pub struct ResolveVisitor(pub F1); -impl<'a, 'b, E, E2, Err, F1> ExprFFallibleVisitor<'a, Expr, Expr, E, E2> +impl<'a, 'b, E, Err, F1> ExprFFallibleVisitor<'a, Expr, Expr, E, E> for &'b mut ResolveVisitor where - F1: FnMut(&Import>) -> Result, + E: Clone, + F1: FnMut(&Import>) -> Result, { type Error = Err; fn visit_subexpr( &mut self, subexpr: &'a Expr, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { Ok(subexpr.rewrap( subexpr .as_ref() .traverse_resolve_with_visitor(&mut **self)?, )) } - fn visit_embed(self, _embed: &'a E) -> Result { - unimplemented!() + fn visit_embed(self, embed: &'a E) -> Result { + Ok(embed.clone()) } } -- cgit v1.2.3