[][src]Struct heaparray::naive_rc::generic::RcArray

#[repr(transparent)]
pub struct RcArray<A, R, E, L = ()> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
{ /* fields omitted */ }

RcArray is a generic, implementation-agnositc array. It contains logic for enforcing type safety.

The type parameters are, in order:

A: A struct that acts as a reference to an array.
R: A reference-counting structure, that wraps the label. Note that this
   *can be the label itself*. It just needs to have defined ways of incrementing
   and decrementing its reference count.
E: The elements that this array contains.
L: The label that is associated with this array.

Methods

impl<A, R, E, L> RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

pub fn ref_count(&self) -> usize[src]

Returns the reference count of the data this RcArray points to.

pub fn to_owned(self) -> Result<A, Self>[src]

Returns an owned version of this array if the caller has exclusive access, or returns back this reference otherwise.

pub fn to_mut(&mut self) -> Option<&mut A>[src]

Returns a mutable reference to the array if the caller has exclusive access, or None otherwise.

impl<A, R, E, L> RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + Clone,
    R: RefCounter<L>, 
[src]

pub fn make_owned(self) -> A[src]

Returns an owned version of this array if the caller has exclusive access, or copies the data otherwise.

pub fn make_mut(&mut self) -> &mut A[src]

Returns a mutable reference to the array if the caller has exclusive access, or copies the data otherwise.

Trait Implementations

impl<A, R, E, L> ArrayRef for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

fn clone(ptr: &Self) -> Self[src]

Clones the array reference. Internally just calls its .clone() method. Read more

impl<A, R, E, L> LabelledArray<E, L> for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

impl<A, R, E, L> DefaultLabelledArray<E, L> for RcArray<A, R, E, L> where
    A: DefaultLabelledArray<E, R> + LabelledArray<E, R>,
    R: RefCounter<L>,
    E: Default
[src]

impl<A, R, E> MakeArray<E> for RcArray<A, R, E, ()> where
    A: LabelledArray<E, R>,
    R: RefCounter<()>, 
[src]

impl<A, R, E, L> SliceArray<E> for RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + SliceArray<E>,
    R: RefCounter<L>, 
[src]

impl<A, R, E, L> Send for RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + Send + Sync,
    R: RefCounter<L> + Send + Sync,
    E: Send + Sync,
    L: Send + Sync
[src]

impl<A, R, E, L> Drop for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

impl<'b, A, R, E, L> IntoIterator for &'b RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + SliceArray<E>,
    R: RefCounter<L>, 
[src]

type Item = &'b E

The type of the elements being iterated over.

type IntoIter = Iter<'b, E>

Which kind of iterator are we turning this into?

impl<A, R, E, L> Sync for RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + Send + Sync,
    R: RefCounter<L> + Send + Sync,
    E: Send + Sync,
    L: Send + Sync
[src]

impl<A, R, E, L> Clone for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<A, R, E, L> Index<usize> for RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + Index<usize, Output = E>,
    R: RefCounter<L>, 
[src]

type Output = E

The returned type after indexing.

impl<A, R, E, L> Debug for RcArray<A, R, E, L> where
    A: LabelledArray<E, R> + SliceArray<E>,
    R: RefCounter<L>,
    E: Debug,
    L: Debug
[src]

impl<A, R, E, L> Container for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

impl<A, R, E, L> CopyMap<usize, E> for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

fn get(&self, key: usize) -> Option<&E>[src]

Get a reference into this array. Returns None if:

  • The index given is out-of-bounds

fn get_mut(&mut self, key: usize) -> Option<&mut E>[src]

Get a mutable reference into this array. Returns None if:

  • The array is referenced by another pointer
  • The index given is out-of-bounds

fn insert(&mut self, key: usize, value: E) -> Option<E>[src]

Insert an element into this array. Returns None if:

  • The array is referenced by another pointer
  • The index given is out-of-bounds
  • There was nothing in the slot previously

Auto Trait Implementations

impl<A, R, E, L> Unpin for RcArray<A, R, E, L> where
    A: Unpin,
    E: Unpin,
    L: Unpin,
    R: Unpin

impl<A, R, E, L> UnwindSafe for RcArray<A, R, E, L> where
    A: UnwindSafe,
    E: UnwindSafe,
    L: UnwindSafe,
    R: UnwindSafe

impl<A, R, E, L> RefUnwindSafe for RcArray<A, R, E, L> where
    A: RefUnwindSafe,
    E: RefUnwindSafe,
    L: RefUnwindSafe,
    R: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]