refactor(tvix/eval): add ThunkRepr::is_forced()
Change-Id: I4eab5c81fb82337da06327248845cd2f3a4490d3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10038 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: Adam Joseph <adam@westernsemico.com>
This commit is contained in:
parent
b5a15989cd
commit
512346ba0b
1 changed files with 9 additions and 5 deletions
|
@ -114,6 +114,14 @@ impl ThunkRepr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_forced(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
ThunkRepr::Evaluated(Value::Thunk(_)) => false,
|
||||||
|
ThunkRepr::Evaluated(_) => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A thunk is created for any value which requires non-strict
|
/// A thunk is created for any value which requires non-strict
|
||||||
|
@ -279,11 +287,7 @@ impl Thunk {
|
||||||
|
|
||||||
/// Returns true if forcing this thunk will not change it.
|
/// Returns true if forcing this thunk will not change it.
|
||||||
pub fn is_forced(&self) -> bool {
|
pub fn is_forced(&self) -> bool {
|
||||||
match *self.0.borrow() {
|
self.0.borrow().is_forced()
|
||||||
ThunkRepr::Evaluated(Value::Thunk(_)) => false,
|
|
||||||
ThunkRepr::Evaluated(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the inner evaluated value of a thunk.
|
/// Returns a reference to the inner evaluated value of a thunk.
|
||||||
|
|
Loading…
Reference in a new issue