Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit fd068a8

Browse files
committed
simplify cache borrowing
1 parent fe0d8dc commit fd068a8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/eval.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ impl std::fmt::Debug for Tree {
6767
impl Tree {
6868
/// Lazily evaluate a Tree, caching its value
6969
pub fn eval(&self) -> Result<Gc<NixValue>, EvalError> {
70-
use std::ops::Deref;
71-
let value_borrow = self.value.borrow();
72-
if let Some(ref value) = value_borrow.deref() {
70+
let mut value_borrow = self.value.borrow_mut();
71+
if let Some(ref value) = *value_borrow {
7372
Ok(value.clone())
7473
} else {
75-
drop(value_borrow);
7674
// We can later build a stack trace by wrapping errors here
7775
let value = self.eval_uncached()?;
78-
*self.value.borrow_mut() = Some(value.clone());
76+
*value_borrow = Some(value.clone());
7977
Ok(value)
8078
}
8179
}

0 commit comments

Comments
 (0)