diff options
author | Nadrieril | 2019-09-02 23:07:12 +0200 |
---|---|---|
committer | Nadrieril | 2019-09-03 11:40:25 +0200 |
commit | 250525a05e1af17bb46ceb72879f471e54fb5091 (patch) | |
tree | fca819c7a7900492183b04e50494fa174d956125 /dhall_syntax | |
parent | 468977575c68ac4cc3a57395ace4095db50e8947 (diff) |
No need to change the type of Embed when resolving anymore
Diffstat (limited to '')
-rw-r--r-- | dhall_syntax/src/core/expr.rs | 25 | ||||
-rw-r--r-- | dhall_syntax/src/core/visitor.rs | 11 |
2 files changed, 22 insertions, 14 deletions
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<SE, E> ExprF<SE, E> { } impl<E> RawExpr<E> { - pub fn traverse_resolve<E2, Err>( + pub fn traverse_resolve<Err>( &self, - visit_import: impl FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, - ) -> Result<RawExpr<E2>, Err> { + visit_import: impl FnMut(&Import<Expr<E>>) -> Result<E, Err>, + ) -> Result<RawExpr<E>, Err> + where + E: Clone, + { self.traverse_resolve_with_visitor(&mut visitor::ResolveVisitor( visit_import, )) } - pub(crate) fn traverse_resolve_with_visitor<E2, Err, F1>( + pub(crate) fn traverse_resolve_with_visitor<Err, F1>( &self, visitor: &mut visitor::ResolveVisitor<F1>, - ) -> Result<RawExpr<E2>, Err> + ) -> Result<RawExpr<E>, Err> where - F1: FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, + E: Clone, + F1: FnMut(&Import<Expr<E>>) -> Result<E, Err>, { match self { ExprF::BinOp(BinOp::ImportAlt, l, r) => l @@ -368,10 +372,13 @@ impl<E> Expr<E> { } impl<E> Expr<E> { - pub fn traverse_resolve<E2, Err>( + pub fn traverse_resolve<Err>( &self, - visit_import: impl FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, - ) -> Result<Expr<E2>, Err> { + visit_import: impl FnMut(&Import<Expr<E>>) -> Result<E, Err>, + ) -> Result<Expr<E>, 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<F1>(pub F1); -impl<'a, 'b, E, E2, Err, F1> ExprFFallibleVisitor<'a, Expr<E>, Expr<E2>, E, E2> +impl<'a, 'b, E, Err, F1> ExprFFallibleVisitor<'a, Expr<E>, Expr<E>, E, E> for &'b mut ResolveVisitor<F1> where - F1: FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, + E: Clone, + F1: FnMut(&Import<Expr<E>>) -> Result<E, Err>, { type Error = Err; fn visit_subexpr( &mut self, subexpr: &'a Expr<E>, - ) -> Result<Expr<E2>, Self::Error> { + ) -> Result<Expr<E>, Self::Error> { Ok(subexpr.rewrap( subexpr .as_ref() .traverse_resolve_with_visitor(&mut **self)?, )) } - fn visit_embed(self, _embed: &'a E) -> Result<E2, Self::Error> { - unimplemented!() + fn visit_embed(self, embed: &'a E) -> Result<E, Self::Error> { + Ok(embed.clone()) } } |