summaryrefslogtreecommitdiff
path: root/serde_dhall/src
diff options
context:
space:
mode:
authorNadrieril2020-02-11 19:04:44 +0000
committerNadrieril2020-02-11 19:04:44 +0000
commit40bee3cdcb9ac0c76996feeceb6ca160a6bd8b42 (patch)
treecf764db516eee081be11587d66569961645a48eb /serde_dhall/src
parentcab75190e86e8fd4ccc209499c0e7f300a669022 (diff)
Introduce LitKind to factor out common enum nodes
Diffstat (limited to 'serde_dhall/src')
-rw-r--r--serde_dhall/src/serde.rs11
1 files changed, 6 insertions, 5 deletions
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());