about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-11-24T08·39-0800
committerclbot <clbot@tvl.fyi>2022-11-26T11·44+0000
commit6b986de92b19d6d4932da74e34a417a88fc63cb3 (patch)
tree06f70b97e1625efd7bc565d40722cc108f84e364 /tvix/eval
parent0616976f7c4be17d375aefaa3df9ba8088bd57a0 (diff)
feat(tvix/eval): add Closure::ptr_eq() r/5325
See cl/7368

Change-Id: I97630994c3d65f4d16414a0da236ce000a5b6d33
Signed-off-by: Adam Joseph <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7374
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/value/function.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/value/function.rs b/tvix/eval/src/value/function.rs
index 9ac35d43d837..7a21223e0400 100644
--- a/tvix/eval/src/value/function.rs
+++ b/tvix/eval/src/value/function.rs
@@ -79,6 +79,12 @@ impl Closure {
         )
     }
 
+    /// Do not call this function unless you have read
+    /// `tvix/docs/value-pointer-equality.md` carefully.
+    pub fn ptr_eq(&self, other: &Self) -> bool {
+        Rc::ptr_eq(&self.lambda, &other.lambda) && Rc::ptr_eq(&self.upvalues, &other.upvalues)
+    }
+
     pub fn new_with_upvalues(upvalues: Rc<Upvalues>, lambda: Rc<Lambda>) -> Self {
         Closure {
             upvalues,