From f1c3d1d7487fbb18b228a1082fc1c966f34b6dc3 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 3 Sep 2019 16:44:02 +0200 Subject: Add mapping functions to InterpolatedTextContents --- dhall/src/core/valuef.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'dhall/src/core/valuef.rs') diff --git a/dhall/src/core/valuef.rs b/dhall/src/core/valuef.rs index 7a2b51c..4e457e6 100644 --- a/dhall/src/core/valuef.rs +++ b/dhall/src/core/valuef.rs @@ -110,17 +110,11 @@ impl ValueF { ValueF::UnionConstructor(l.clone(), kts.clone()).to_expr(opts), v.to_expr(opts), )), - ValueF::TextLit(elts) => { - use InterpolatedTextContents::{Expr, Text}; - rc(ExprF::TextLit( - elts.iter() - .map(|contents| match contents { - Expr(e) => Expr(e.to_expr(opts)), - Text(s) => Text(s.clone()), - }) - .collect(), - )) - } + ValueF::TextLit(elts) => rc(ExprF::TextLit( + elts.iter() + .map(|contents| contents.map_ref(|e| e.to_expr(opts))) + .collect(), + )), ValueF::Equivalence(x, y) => rc(ExprF::BinOp( dhall_syntax::BinOp::Equivalence, x.to_expr(opts), @@ -187,11 +181,7 @@ impl ValueF { } ValueF::TextLit(elts) => { for x in elts.iter_mut() { - use InterpolatedTextContents::{Expr, Text}; - match x { - Expr(v) => v.normalize_mut(), - Text(_) => {} - } + x.map_mut(Value::normalize_mut); } } ValueF::Equivalence(x, y) => { -- cgit v1.2.3