From 08593ae84ceae4d5f639d5868c08b99f1622795a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 20 Dec 2019 19:07:50 +0000 Subject: Remove Expr::as_mut --- dhall/src/syntax/ast/expr.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs index 410fb1d..48c48d8 100644 --- a/dhall/src/syntax/ast/expr.rs +++ b/dhall/src/syntax/ast/expr.rs @@ -235,9 +235,6 @@ impl Expr { pub fn as_ref(&self) -> &UnspannedExpr { &self.kind } - pub fn as_mut(&mut self) -> &mut UnspannedExpr { - &mut self.kind - } pub fn span(&self) -> Span { self.span.clone() } @@ -264,7 +261,7 @@ impl Expr { E: Clone, F1: FnMut(Import>) -> Result, { - match self.as_mut() { + match self.kind.as_mut() { ExprKind::BinOp(BinOp::ImportAlt, l, r) => { let garbage_expr = ExprKind::BoolLit(false); let new_self = if l.traverse_resolve_mut(f).is_ok() { @@ -273,12 +270,12 @@ impl Expr { r.traverse_resolve_mut(f)?; r }; - *self.as_mut() = - std::mem::replace(new_self.as_mut(), garbage_expr); + *self.kind = + std::mem::replace(new_self.kind.as_mut(), garbage_expr); } _ => { - self.as_mut().traverse_mut(|e| e.traverse_resolve_mut(f))?; - if let ExprKind::Import(import) = self.as_mut() { + self.kind.traverse_mut(|e| e.traverse_resolve_mut(f))?; + if let ExprKind::Import(import) = self.kind.as_mut() { let garbage_import = Import { mode: ImportMode::Code, location: ImportLocation::Missing, @@ -286,7 +283,7 @@ impl Expr { }; // Move out of &mut import let import = std::mem::replace(import, garbage_import); - *self.as_mut() = ExprKind::Embed(f(import)?); + *self.kind = ExprKind::Embed(f(import)?); } } } -- cgit v1.2.3