From 40bee3cdcb9ac0c76996feeceb6ca160a6bd8b42 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 11 Feb 2020 19:04:44 +0000 Subject: Introduce LitKind to factor out common enum nodes --- serde_dhall/src/serde.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/serde.rs b/serde_dhall/src/serde.rs index 92a0015..160392d 100644 --- a/serde_dhall/src/serde.rs +++ b/serde_dhall/src/serde.rs @@ -4,7 +4,7 @@ use serde::de::value::{ MapAccessDeserializer, MapDeserializer, SeqDeserializer, }; -use dhall::syntax::ExprKind; +use dhall::syntax::{ExprKind, LitKind}; use dhall::NormalizedExpr; use crate::de::{Deserialize, Error, Result}; @@ -39,6 +39,7 @@ impl<'de: 'a, 'a> serde::Deserializer<'de> for Deserializer<'a> { { use std::convert::TryInto; use ExprKind::*; + use LitKind::*; let expr = self.0.as_ref(); let not_serde_compatible = || { Err(Error::Deserialize(format!( @@ -48,8 +49,8 @@ impl<'de: 'a, 'a> serde::Deserializer<'de> for Deserializer<'a> { }; match expr.as_ref() { - BoolLit(x) => visitor.visit_bool(*x), - NaturalLit(x) => { + Lit(Bool(x)) => visitor.visit_bool(*x), + Lit(Natural(x)) => { if let Ok(x64) = (*x).try_into() { visitor.visit_u64(x64) } else if let Ok(x32) = (*x).try_into() { @@ -58,7 +59,7 @@ impl<'de: 'a, 'a> serde::Deserializer<'de> for Deserializer<'a> { unimplemented!() } } - IntegerLit(x) => { + Lit(Integer(x)) => { if let Ok(x64) = (*x).try_into() { visitor.visit_i64(x64) } else if let Ok(x32) = (*x).try_into() { @@ -67,7 +68,7 @@ impl<'de: 'a, 'a> serde::Deserializer<'de> for Deserializer<'a> { unimplemented!() } } - DoubleLit(x) => visitor.visit_f64((*x).into()), + Lit(Double(x)) => visitor.visit_f64((*x).into()), TextLit(x) => { // Normal form ensures that the tail is empty. assert!(x.tail().is_empty()); -- cgit v1.2.3