From 6b986de92b19d6d4932da74e34a417a88fc63cb3 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 24 Nov 2022 00:39:37 -0800 Subject: feat(tvix/eval): add Closure::ptr_eq() See cl/7368 Change-Id: I97630994c3d65f4d16414a0da236ce000a5b6d33 Signed-off-by: Adam Joseph Reviewed-on: https://cl.tvl.fyi/c/depot/+/7374 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/value/function.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix/eval') diff --git a/tvix/eval/src/value/function.rs b/tvix/eval/src/value/function.rs index 9ac35d43d8..7a21223e04 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, lambda: Rc) -> Self { Closure { upvalues, -- cgit 1.4.1