diff options
author | Nadrieril | 2020-05-10 22:09:43 +0100 |
---|---|---|
committer | Nadrieril | 2020-10-28 22:52:41 +0000 |
commit | e070270c3f1f10d46281ed7751ff95e15092e7f4 (patch) | |
tree | 46c22c75f209c5112030f3db6609ed64ff4888d3 /serde_dhall/src/options.rs | |
parent | 5f3ca811f09dcf6f09fb9b60fcd2664d06762f39 (diff) |
Implement serialization
Diffstat (limited to '')
-rw-r--r-- | serde_dhall/src/options/de.rs (renamed from serde_dhall/src/options.rs) | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/serde_dhall/src/options.rs b/serde_dhall/src/options/de.rs index 7b27114..8ff794d 100644 --- a/serde_dhall/src/options.rs +++ b/serde_dhall/src/options/de.rs @@ -19,20 +19,20 @@ pub struct ManualAnnot<'ty>(&'ty SimpleType); #[derive(Debug, Clone, Copy)] pub struct StaticAnnot; -pub trait HasAnnot<A> { +pub trait OptionalAnnot<A> { fn get_annot(a: &A) -> Option<SimpleType>; } -impl<T> HasAnnot<NoAnnot> for T { +impl<T> OptionalAnnot<NoAnnot> for T { fn get_annot(_: &NoAnnot) -> Option<SimpleType> { None } } -impl<'ty, T> HasAnnot<ManualAnnot<'ty>> for T { +impl<'ty, T> OptionalAnnot<ManualAnnot<'ty>> for T { fn get_annot(a: &ManualAnnot<'ty>) -> Option<SimpleType> { Some(a.0.clone()) } } -impl<T: StaticType> HasAnnot<StaticAnnot> for T { +impl<T: StaticType> OptionalAnnot<StaticAnnot> for T { fn get_annot(_: &StaticAnnot) -> Option<SimpleType> { Some(T::static_type()) } @@ -252,7 +252,7 @@ impl<'a, A> Deserializer<'a, A> { fn _parse<T>(&self) -> dhall::error::Result<Value> where - T: HasAnnot<A>, + T: OptionalAnnot<A>, { let parsed = match &self.source { Source::Str(s) => Parsed::parse_str(s)?, @@ -287,7 +287,7 @@ impl<'a, A> Deserializer<'a, A> { /// [`StaticType`]: trait.StaticType.html pub fn parse<T>(&self) -> Result<T> where - T: FromDhall + HasAnnot<A>, + T: FromDhall + OptionalAnnot<A>, { let val = self ._parse::<T>() |