diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-11-14T18·22-0800 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-11-25T02·55+0000 |
commit | 512346ba0b85c89fc0d16558962c3a946a8c98c3 (patch) | |
tree | 5cabfe46c3905a59ea99fe1a1016eeef741bb808 /tvix/eval/src/value/thunk.rs | |
parent | b5a15989cddd8c1eb05ef648b0df1dc631daf9f2 (diff) |
refactor(tvix/eval): add ThunkRepr::is_forced() r/7055
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>
Diffstat (limited to 'tvix/eval/src/value/thunk.rs')
-rw-r--r-- | tvix/eval/src/value/thunk.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index 1ff5beb0d472..2853a398decc 100644 --- a/tvix/eval/src/value/thunk.rs +++ b/tvix/eval/src/value/thunk.rs @@ -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 @@ -279,11 +287,7 @@ impl Thunk { /// Returns true if forcing this thunk will not change it. pub fn is_forced(&self) -> bool { - match *self.0.borrow() { - ThunkRepr::Evaluated(Value::Thunk(_)) => false, - ThunkRepr::Evaluated(_) => true, - _ => false, - } + self.0.borrow().is_forced() } /// Returns a reference to the inner evaluated value of a thunk. |