From 7fbefc082abd94e3170015b005a14a02593f8b51 Mon Sep 17 00:00:00 2001 From: Daniel Gurgel Date: Thu, 25 Jul 2024 07:49:26 -0300 Subject: [PATCH] is_unique for arcarray --- src/impl_arc_array.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/impl_arc_array.rs b/src/impl_arc_array.rs index 724cfe51d..f88f8083e 100644 --- a/src/impl_arc_array.rs +++ b/src/impl_arc_array.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use alloc::sync::Arc; use crate::imp_prelude::*; +use alloc::sync::Arc; /// Methods specific to `ArcArray`. /// @@ -17,7 +17,9 @@ where D: Dimension, { /// Returns `true` iff the inner `Arc` is not shared. - pub fn is_unique(&mut self) -> bool { - Arc::get_mut(&mut self.data.0).is_some() + /// If you want to ensure the Arc is not concurrently cloned, you need to provide a `&mut self` to this function. + pub fn is_unique(&self) -> bool { + // Only strong pointers are used in this crate. + Arc::strong_count(&self.data.0) == 1 } }