From e97e0c8e9905582aef826504b59a1844c8f67613 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 27 Dec 2019 15:29:59 +0000 Subject: Make TypecheckContext a named struct --- dhall/src/semantics/core/context.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'dhall/src/semantics') diff --git a/dhall/src/semantics/core/context.rs b/dhall/src/semantics/core/context.rs index c198e8e..5a0c320 100644 --- a/dhall/src/semantics/core/context.rs +++ b/dhall/src/semantics/core/context.rs @@ -13,29 +13,31 @@ enum CtxItem { } #[derive(Debug, Clone)] -pub(crate) struct TypecheckContext(Vec<(Label, CtxItem)>); +pub(crate) struct TypecheckContext { + ctx: Vec<(Label, CtxItem)>, +} impl TypecheckContext { pub fn new() -> Self { - TypecheckContext(Vec::new()) + TypecheckContext { ctx: Vec::new() } } fn with_vec(&self, vec: Vec<(Label, CtxItem)>) -> Self { - TypecheckContext(vec) + TypecheckContext { ctx: vec } } pub fn insert_type(&self, x: &Label, t: Value) -> Self { - let mut vec = self.0.clone(); + let mut vec = self.ctx.clone(); vec.push((x.clone(), CtxItem::Kept(x.into(), t.under_binder(x)))); self.with_vec(vec) } pub fn insert_value(&self, x: &Label, e: Value) -> Result { - let mut vec = self.0.clone(); + let mut vec = self.ctx.clone(); vec.push((x.clone(), CtxItem::Replaced(e))); Ok(self.with_vec(vec)) } pub fn lookup(&self, var: &V