mirror of
https://github.com/tweag/nickel.git
synced 2024-11-10 10:46:49 +03:00
Formatting
This commit is contained in:
parent
0d5cc3b568
commit
e0a64dca82
42
src/eval.rs
42
src/eval.rs
@ -591,26 +591,28 @@ where
|
||||
// Thanks to the share normal form transformation, the content is either a constant or a
|
||||
// variable.
|
||||
let rec_env = ts.iter().try_fold::<_, _, Result<Environment, EvalError>>(
|
||||
HashMap::new(), |mut rec_env, (id, rt)| match rt.as_ref() {
|
||||
Term::Var(ref var_id) => {
|
||||
let thunk = env.get(var_id).ok_or_else(|| {
|
||||
EvalError::UnboundIdentifier(var_id.clone(), rt.pos.clone())
|
||||
})?;
|
||||
rec_env.insert(id.clone(), thunk.clone());
|
||||
Ok(rec_env)
|
||||
}
|
||||
_ => {
|
||||
// If we are in this branch, the term must be a constant after the
|
||||
// share normal form transformation, hence it should not need an
|
||||
// environment, which is why it is dropped.
|
||||
let closure = Closure {
|
||||
body: rt.clone(),
|
||||
env: HashMap::new(),
|
||||
};
|
||||
rec_env.insert(id.clone(), Thunk::new(closure, IdentKind::Let()));
|
||||
Ok(rec_env)
|
||||
}
|
||||
})?;
|
||||
HashMap::new(),
|
||||
|mut rec_env, (id, rt)| match rt.as_ref() {
|
||||
Term::Var(ref var_id) => {
|
||||
let thunk = env.get(var_id).ok_or_else(|| {
|
||||
EvalError::UnboundIdentifier(var_id.clone(), rt.pos.clone())
|
||||
})?;
|
||||
rec_env.insert(id.clone(), thunk.clone());
|
||||
Ok(rec_env)
|
||||
}
|
||||
_ => {
|
||||
// If we are in this branch, the term must be a constant after the
|
||||
// share normal form transformation, hence it should not need an
|
||||
// environment, which is why it is dropped.
|
||||
let closure = Closure {
|
||||
body: rt.clone(),
|
||||
env: HashMap::new(),
|
||||
};
|
||||
rec_env.insert(id.clone(), Thunk::new(closure, IdentKind::Let()));
|
||||
Ok(rec_env)
|
||||
}
|
||||
},
|
||||
)?;
|
||||
|
||||
let new_ts = ts.into_iter().map(|(id, rt)| {
|
||||
let RichTerm { term, pos } = rt;
|
||||
|
Loading…
Reference in New Issue
Block a user