summaryrefslogtreecommitdiff
path: root/dhall_generator
diff options
context:
space:
mode:
authorNadrieril2019-03-31 21:04:10 +0200
committerNadrieril2019-03-31 21:04:10 +0200
commit62970fd2010b01260cf45a1f2a6a582c6a8c0c12 (patch)
tree483b2661c61781b80a98ca9985a76280392e327f /dhall_generator
parentc4fe2f4290089437d3ff1d6d15df58b4cf29a11e (diff)
Make Expr generic in Label
Diffstat (limited to '')
-rw-r--r--dhall_generator/src/dhall_expr.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/dhall_generator/src/dhall_expr.rs b/dhall_generator/src/dhall_expr.rs
index 96201e8..b057850 100644
--- a/dhall_generator/src/dhall_expr.rs
+++ b/dhall_generator/src/dhall_expr.rs
@@ -17,17 +17,20 @@ pub fn dhall_expr(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
// Returns an expression of type ExprF<T, _, _>, where T is the
// type of the subexpressions after interpolation.
-pub fn quote_expr<TS>(expr: ExprF<TS, X, X>) -> TokenStream
+pub fn quote_expr<TS>(expr: ExprF<TS, Label, X, X>) -> TokenStream
where
TS: quote::ToTokens + std::fmt::Debug,
{
let quote_map = |m: BTreeMap<Label, TS>| -> TokenStream {
- let (keys, values): (Vec<TokenStream>, Vec<TS>) =
- m.into_iter().map(|(k, v)| (quote_label(&k), v)).unzip();
+ let entries =
+ m.into_iter().map(|(k, v)| {
+ let k = quote_label(&k);
+ quote!(m.insert(#k, #v);)
+ });
quote! { {
use std::collections::BTreeMap;
let mut m = BTreeMap::new();
- #( m.insert(#keys, #values); )*
+ #( #entries )*
m
} }
};
@@ -151,7 +154,7 @@ fn quote_binop(b: BinOp) -> TokenStream {
fn quote_label(l: &Label) -> TokenStream {
let l = String::from(l);
- quote! { #l.into() }
+ quote! { dhall_core::Label::from(#l) }
}
fn bx(x: TokenStream) -> TokenStream {