From 22aa0081d314453bd1bb607384da3ed983dc4364 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 18 Apr 2019 11:42:05 +0200 Subject: Simplify implementation of shift and subst_shift --- dhall_core/src/core.rs | 58 +++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'dhall_core') diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 2dfa4d8..bfe769f 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -375,11 +375,7 @@ impl SubExpr { self.0.as_ref() } - pub fn map_ref<'a, F1, F2>( - &'a self, - map_expr: F1, - map_under_binder: F2, - ) -> Self + fn map_ref<'a, F1, F2>(&'a self, map_expr: F1, map_under_binder: F2) -> Self where F1: FnMut(&'a Self) -> Self, F2: FnMut(&'a Label, &'a Self) -> Self, @@ -493,6 +489,18 @@ fn add_ui(u: usize, i: isize) -> usize { } } +/// Applies `shift` to a single var. +/// The first var is the var to shift away from; the second is the variable to shift +fn shift_var(delta: isize, var: &V