From 0f4a4801ed67826dc82015d39ce8fd05e7950035 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 17 Jan 2020 18:42:13 +0000 Subject: Replace all bulk shifting by a single shift --- dhall/src/semantics/core/var.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'dhall/src/semantics/core/var.rs') diff --git a/dhall/src/semantics/core/var.rs b/dhall/src/semantics/core/var.rs index f3475e7..93776bf 100644 --- a/dhall/src/semantics/core/var.rs +++ b/dhall/src/semantics/core/var.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use crate::syntax::{Label, V}; /// Stores an alpha-normalized variable. @@ -16,6 +14,9 @@ pub struct Binder { } impl AlphaVar { + pub(crate) fn default() -> Self { + AlphaVar { alpha: V((), 0) } + } pub(crate) fn idx(&self) -> usize { self.alpha.idx() } @@ -35,14 +36,6 @@ impl AlphaVar { pub(crate) fn over_binder(&self, x: &AlphaVar) -> Option { self.shift(-1, x) } - pub(crate) fn under_multiple_binders( - &self, - shift_map: &HashMap, - ) -> Self { - AlphaVar { - alpha: self.alpha.under_multiple_binders(shift_map), - } - } } impl Binder { @@ -89,11 +82,6 @@ impl std::fmt::Debug for Binder { } } -impl<'a> From<&'a Label> for AlphaVar { - fn from(x: &'a Label) -> AlphaVar { - AlphaVar { alpha: V((), 0) } - } -} impl From for AlphaVar { fn from(x: Binder) -> AlphaVar { AlphaVar { alpha: V((), 0) } @@ -101,7 +89,7 @@ impl From for AlphaVar { } impl<'a> From<&'a Binder> for AlphaVar { fn from(x: &'a Binder) -> AlphaVar { - x.clone().into() + AlphaVar { alpha: V((), 0) } } } -- cgit v1.2.3