summaryrefslogtreecommitdiff
path: root/serde_dhall
diff options
context:
space:
mode:
authorNadrieril Feneanar2020-02-19 17:25:57 +0000
committerGitHub2020-02-19 17:25:57 +0000
commitffbde252a850c7d96e1000e1be52792c41733a28 (patch)
treee668b7f764fb4981a802bc619e0b2ff62fa9ce16 /serde_dhall
parente4b3a879907b6dcc75d25847ae21a23d0201aae1 (diff)
parent7cbfc1a0d32766a383d1f48902502adaa2234d2f (diff)
Merge pull request #131 from Nadrieril/hir
Decouple main expression types
Diffstat (limited to 'serde_dhall')
-rw-r--r--serde_dhall/src/serde.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/serde_dhall/src/serde.rs b/serde_dhall/src/serde.rs
index 3e78987..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());
@@ -115,7 +116,7 @@ impl<'de: 'a, 'a> serde::Deserializer<'de> for Deserializer<'a> {
| Assert(..) | Builtin(..) | BinOp(..) | BoolIf(..)
| RecordType(..) | UnionType(..) | Merge(..) | ToMap(..)
| Projection(..) | ProjectionByExpr(..) | Completion(..)
- | Import(..) | Embed(..) => not_serde_compatible(),
+ | Import(..) => not_serde_compatible(),
}
}