summaryrefslogtreecommitdiff
path: root/dhall_core
diff options
context:
space:
mode:
authorNadrieril2019-04-06 13:49:49 +0200
committerNadrieril2019-04-06 13:49:49 +0200
commitf20aa69322394e648ebd0556a5862b6211c1061c (patch)
tree9fd65651ac75117fd7dbdc721e317b7ccc63c7ff /dhall_core
parent5176b900bf22cf264ce7e75dd416e9e822719168 (diff)
Factor out the recursion when possible in typecheck
Diffstat (limited to 'dhall_core')
-rw-r--r--dhall_core/src/core.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index 355f625..a56c5a3 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -536,6 +536,27 @@ impl<SE, L, N, E> ExprF<SE, L, N, E> {
)
}
+ #[inline(always)]
+ pub fn traverse_ref_simple<'a, SE2, Err, F1>(
+ &'a self,
+ map_subexpr: F1,
+ ) -> Result<ExprF<SE2, L, N, E>, Err>
+ where
+ L: Ord,
+ L: Clone,
+ N: Clone,
+ E: Clone,
+ F1: Fn(&'a SE) -> Result<SE2, Err>,
+ {
+ self.as_ref().traverse(
+ &map_subexpr,
+ |_, e| map_subexpr(e),
+ |x| Ok(N::clone(x)),
+ |x| Ok(E::clone(x)),
+ |x| Ok(L::clone(x)),
+ )
+ }
+
// #[inline(always)]
// pub fn zip<SE2, L2, N2, E2>(
// self,