From f20aa69322394e648ebd0556a5862b6211c1061c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 6 Apr 2019 13:49:49 +0200 Subject: Factor out the recursion when possible in typecheck --- dhall_core/src/core.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'dhall_core') 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 ExprF { ) } + #[inline(always)] + pub fn traverse_ref_simple<'a, SE2, Err, F1>( + &'a self, + map_subexpr: F1, + ) -> Result, Err> + where + L: Ord, + L: Clone, + N: Clone, + E: Clone, + F1: Fn(&'a SE) -> Result, + { + 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( // self, -- cgit v1.2.3