diff options
author | Nadrieril | 2020-03-22 22:11:00 +0000 |
---|---|---|
committer | Nadrieril | 2020-03-31 21:45:31 +0100 |
commit | a70922c6c6beb58a45da80f15576b54fb915ec28 (patch) | |
tree | 13ec93aef7a8d5bb717b7722116c58f76a57dc36 /serde_dhall/src/static_type.rs | |
parent | fd4a81b1a92c1859941538b7f2212c621f4b43fd (diff) |
Rework SimpleType
Diffstat (limited to '')
-rw-r--r-- | serde_dhall/src/static_type.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/serde_dhall/src/static_type.rs b/serde_dhall/src/static_type.rs index 3fdff39..ffbc3ad 100644 --- a/serde_dhall/src/static_type.rs +++ b/serde_dhall/src/static_type.rs @@ -1,4 +1,4 @@ -use crate::simple::{TyKind, Type}; +use crate::SimpleType; /// A Rust type that can be represented as a Dhall type. /// @@ -13,14 +13,14 @@ use crate::simple::{TyKind, Type}; /// have a different Dhall record type. /// TODO pub trait StaticType { - fn static_type() -> Type; + fn static_type() -> SimpleType; } macro_rules! derive_builtin { ($rust_ty:ty, $dhall_ty:ident) => { impl StaticType for $rust_ty { - fn static_type() -> Type { - Type::new(TyKind::$dhall_ty) + fn static_type() -> SimpleType { + SimpleType::$dhall_ty } } }; @@ -42,8 +42,8 @@ where A: StaticType, B: StaticType, { - fn static_type() -> Type { - TyKind::Record( + fn static_type() -> SimpleType { + SimpleType::Record( vec![ ("_1".to_owned(), A::static_type()), ("_2".to_owned(), B::static_type()), @@ -60,8 +60,8 @@ where T: StaticType, E: StaticType, { - fn static_type() -> Type { - TyKind::Union( + fn static_type() -> SimpleType { + SimpleType::Union( vec![ ("Ok".to_owned(), Some(T::static_type())), ("Err".to_owned(), Some(E::static_type())), @@ -77,8 +77,8 @@ impl<T> StaticType for Option<T> where T: StaticType, { - fn static_type() -> Type { - TyKind::Optional(T::static_type()).into() + fn static_type() -> SimpleType { + SimpleType::Optional(Box::new(T::static_type())).into() } } @@ -86,8 +86,8 @@ impl<T> StaticType for Vec<T> where T: StaticType, { - fn static_type() -> Type { - TyKind::List(T::static_type()).into() + fn static_type() -> SimpleType { + SimpleType::List(Box::new(T::static_type())).into() } } @@ -95,7 +95,7 @@ impl<'a, T> StaticType for &'a T where T: StaticType, { - fn static_type() -> Type { + fn static_type() -> SimpleType { T::static_type() } } |