From 845abbb0404ac15cefeca8b6ac32d9b3f93e5987 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 21 Mar 2019 16:36:46 +0100 Subject: Represent Optional literals more faithfully --- dhall_generator/src/lib.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'dhall_generator/src/lib.rs') diff --git a/dhall_generator/src/lib.rs b/dhall_generator/src/lib.rs index a246818..328bc3e 100644 --- a/dhall_generator/src/lib.rs +++ b/dhall_generator/src/lib.rs @@ -63,10 +63,13 @@ fn dhall_to_tokenstream( NaturalLit(n) => { quote! { NaturalLit(#n) } } - OptionalLit(t, e) => { - let t = option_to_tokenstream(t, ctx); - let e = option_to_tokenstream(e, ctx); - quote! { OptionalLit(#t, #e) } + EmptyOptionalLit(x) => { + let x = dhall_to_tokenstream_bx(x, ctx); + quote! { EmptyOptionalLit(#x) } + } + NEOptionalLit(x) => { + let x = dhall_to_tokenstream_bx(x, ctx); + quote! { NEOptionalLit(#x) } } EmptyListLit(t) => { let t = dhall_to_tokenstream_bx(t, ctx); @@ -153,17 +156,6 @@ fn map_to_tokenstream( } } } -fn option_to_tokenstream( - e: &Option, - ctx: &Context, -) -> TokenStream { - let e = e.as_ref().map(|x| dhall_to_tokenstream_bx(x, ctx)); - match e { - Some(x) => quote! { Some(#x) }, - None => quote! { None }, - } -} - fn vec_to_tokenstream( e: &Vec, ctx: &Context, -- cgit v1.2.3