From 9ef70f3d33759240c0ab0f5235a7697abe817d9e Mon Sep 17 00:00:00 2001 From: Sahas Subramanian Date: Sat, 27 Dec 2025 03:17:55 +0100 Subject: [PATCH 1/4] Remove unused `Shared::{new, ptr_eq}` methods --- src/object/wrappers.rs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/object/wrappers.rs b/src/object/wrappers.rs index b9ce14b..cf26ba0 100644 --- a/src/object/wrappers.rs +++ b/src/object/wrappers.rs @@ -51,16 +51,6 @@ pub mod generic { } } - impl Shared { - pub fn new(val: T) -> Self { - Shared(std::rc::Rc::new(val)) - } - - pub fn ptr_eq(&self, other: &Self) -> bool { - std::rc::Rc::ptr_eq(&self.0, &other.0) - } - } - impl Deref for Shared { type Target = T; @@ -173,16 +163,6 @@ pub mod generic { } } - impl Shared { - pub fn new(val: T) -> Self { - Shared(std::sync::Arc::new(val)) - } - - pub fn ptr_eq(&self, other: &Self) -> bool { - std::sync::Arc::ptr_eq(&self.0, &other.0) - } - } - impl Deref for Shared { type Target = T; From 8f16368bf312a45bb2bc8c898a48a2a5edd27df4 Mon Sep 17 00:00:00 2001 From: Sahas Subramanian Date: Sat, 27 Dec 2025 03:18:17 +0100 Subject: [PATCH 2/4] Limit `Shared::new_tulisp_fn` to `pub(crate)` --- src/object/wrappers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/object/wrappers.rs b/src/object/wrappers.rs index cf26ba0..2c92976 100644 --- a/src/object/wrappers.rs +++ b/src/object/wrappers.rs @@ -30,7 +30,7 @@ pub mod generic { } impl Shared { - pub fn new_tulisp_fn(val: impl TulispFn) -> Shared { + pub(crate) fn new_tulisp_fn(val: impl TulispFn) -> Shared { Shared(std::rc::Rc::new(val)) } @@ -142,7 +142,7 @@ pub mod generic { } impl Shared { - pub fn new_tulisp_fn(val: impl TulispFn) -> Shared { + pub(crate) fn new_tulisp_fn(val: impl TulispFn) -> Shared { Shared(std::sync::Arc::new(val)) } From b238b2c1a8a15f7fbc01d8b6aaef9312ce9ff88f Mon Sep 17 00:00:00 2001 From: Sahas Subramanian Date: Sat, 27 Dec 2025 03:19:53 +0100 Subject: [PATCH 3/4] Remove unused `DerefMut` impls for `Shared` and `SharedMut` --- src/object/wrappers.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/object/wrappers.rs b/src/object/wrappers.rs index 2c92976..ad7e73a 100644 --- a/src/object/wrappers.rs +++ b/src/object/wrappers.rs @@ -59,12 +59,6 @@ pub mod generic { } } - impl std::ops::DerefMut for Shared { - fn deref_mut(&mut self) -> &mut Self::Target { - std::rc::Rc::get_mut(&mut self.0).expect("Multiple references exist") - } - } - #[repr(transparent)] #[derive(Clone, Debug)] pub struct SharedMut(std::rc::Rc>); @@ -94,14 +88,6 @@ pub mod generic { } } - impl Deref for SharedMut { - type Target = T; - - fn deref(&self) -> &Self::Target { - todo!() - } - } - pub trait TulispFn: Fn(&mut TulispContext, &TulispObject) -> Result + 'static { From aca2f875f0579b75d78255631f8df80cff3f3f17 Mon Sep 17 00:00:00 2001 From: Sahas Subramanian Date: Sat, 27 Dec 2025 03:21:49 +0100 Subject: [PATCH 4/4] Rename `Shared::new_any` to `Shared::new` --- src/builtin/functions/hash_table.rs | 2 +- src/object.rs | 2 +- src/object/wrappers.rs | 4 ++-- tests/tests.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/builtin/functions/hash_table.rs b/src/builtin/functions/hash_table.rs index 10d2d4f..68ecc2e 100644 --- a/src/builtin/functions/hash_table.rs +++ b/src/builtin/functions/hash_table.rs @@ -49,7 +49,7 @@ pub(crate) fn add(ctx: &mut TulispContext) { ) .with_trace(args.clone())); } - let table = Shared::new_any(HashTable { + let table = Shared::new(HashTable { inner: SharedMut::new(HashMap::new()), }); Ok(table.into()) diff --git a/src/object.rs b/src/object.rs index af1e86b..0e92bf9 100644 --- a/src/object.rs +++ b/src/object.rs @@ -307,7 +307,7 @@ ctx.add_special_form("make_any", |_ctx, args| { destruct_bind!((inp) = args); let inp: i64 = inp.try_into()?; - let any_obj = Shared::new_any(TestStruct { value: inp }); + let any_obj = Shared::new(TestStruct { value: inp }); Ok(any_obj.into()) }); diff --git a/src/object/wrappers.rs b/src/object/wrappers.rs index ad7e73a..9cd6020 100644 --- a/src/object/wrappers.rs +++ b/src/object/wrappers.rs @@ -34,7 +34,7 @@ pub mod generic { Shared(std::rc::Rc::new(val)) } - pub fn new_any(val: impl TulispAny) -> Shared { + pub fn new(val: impl TulispAny) -> Shared { Shared(std::rc::Rc::new(val)) } @@ -132,7 +132,7 @@ pub mod generic { Shared(std::sync::Arc::new(val)) } - pub fn new_any(val: impl TulispAny) -> Shared { + pub fn new(val: impl TulispAny) -> Shared { Shared(std::sync::Arc::new(val)) } diff --git a/tests/tests.rs b/tests/tests.rs index 45242fa..cd1e2ef 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1165,7 +1165,7 @@ fn test_any() -> Result<(), Error> { ctx.add_special_form("make_any", |ctx, args| { destruct_eval_bind!(ctx, (inp) = args); - let res: Shared = Shared::new_any(TestStruct { + let res: Shared = Shared::new(TestStruct { value: inp.try_into()?, });