diff options
author | Nadrieril | 2019-08-04 13:00:56 +0200 |
---|---|---|
committer | Nadrieril | 2019-08-06 21:40:24 +0200 |
commit | 696efe66336a268054c475fab9fe6505bdfc7b60 (patch) | |
tree | 353f9c5edd080e22455dba775fcfc5c6afc0f1fa /dhall_syntax/src/core/visitor.rs | |
parent | 278cd9be7d93bc1eeecde05c964da5b097668016 (diff) |
Add some new tests and implement import alternatives
Diffstat (limited to 'dhall_syntax/src/core/visitor.rs')
-rw-r--r-- | dhall_syntax/src/core/visitor.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs index 1745fdb..b02544f 100644 --- a/dhall_syntax/src/core/visitor.rs +++ b/dhall_syntax/src/core/visitor.rs @@ -358,6 +358,31 @@ where } } +pub struct ResolveVisitor<F1>(pub F1); + +impl<'a, 'b, N, E, E2, Err, F1> + ExprFFallibleVisitor<'a, SubExpr<N, E>, SubExpr<N, E2>, E, E2> + for &'b mut ResolveVisitor<F1> +where + N: Clone + 'a, + F1: FnMut(&E) -> Result<E2, Err>, +{ + type Error = Err; + + fn visit_subexpr( + &mut self, + subexpr: &'a SubExpr<N, E>, + ) -> Result<SubExpr<N, E2>, 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> { + (self.0)(embed) + } +} pub struct NoteAbsurdVisitor; impl<'a, 'b, N, E> |