ndarray/
impl_arc_array.rs

1// Copyright 2019 ndarray developers.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use crate::imp_prelude::*;
10
11#[cfg(target_has_atomic = "ptr")]
12use alloc::sync::Arc;
13
14#[cfg(not(target_has_atomic = "ptr"))]
15use portable_atomic_util::Arc;
16
17/// Methods specific to `ArcArray`.
18///
19/// ***See also all methods for [`ArrayBase`]***
20impl<A, D> ArcArray<A, D>
21where D: Dimension
22{
23    /// Returns `true` iff the inner `Arc` is not shared.
24    /// If you want to ensure the `Arc` is not concurrently cloned, you need to provide a `&mut self` to this function.
25    pub fn is_unique(&self) -> bool
26    {
27        // Only strong pointers are used in this crate.
28        Arc::strong_count(&self.data.0) == 1
29    }
30}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy