summaryrefslogtreecommitdiff
path: root/dhall_generator/src
diff options
context:
space:
mode:
authorNadrieril2019-04-01 00:17:44 +0200
committerNadrieril2019-04-01 00:21:00 +0200
commit57ccbfa16f48f373ac5545b8523de56fb996ba3e (patch)
treee0e2841cc415e3e2d6e1e41de66b509df900a88c /dhall_generator/src
parent62970fd2010b01260cf45a1f2a6a582c6a8c0c12 (diff)
Refactor and clarify various map methods
Diffstat (limited to 'dhall_generator/src')
-rw-r--r--dhall_generator/src/dhall_expr.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/dhall_generator/src/dhall_expr.rs b/dhall_generator/src/dhall_expr.rs
index b057850..9da23b6 100644
--- a/dhall_generator/src/dhall_expr.rs
+++ b/dhall_generator/src/dhall_expr.rs
@@ -22,11 +22,10 @@ where
TS: quote::ToTokens + std::fmt::Debug,
{
let quote_map = |m: BTreeMap<Label, TS>| -> TokenStream {
- let entries =
- m.into_iter().map(|(k, v)| {
- let k = quote_label(&k);
- quote!(m.insert(#k, #v);)
- });
+ 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();
@@ -108,13 +107,12 @@ fn quote_subexpr(
ctx: &Context<Label, ()>,
) -> TokenStream {
use dhall_core::ExprF::*;
- match map_subexpr(
- expr.as_ref(),
+ match expr.as_ref().map_ref(
|e| quote_subexpr(e, ctx),
+ |l, e| quote_subexpr(e, &ctx.insert(l.clone(), ())),
|_| unreachable!(),
|_| unreachable!(),
|l| l.clone(),
- |l, e| quote_subexpr(e, &ctx.insert(l.clone(), ())),
) {
Var(V(ref s, n)) => {
match ctx.lookup(s, n) {