[][src]Struct archery::shared_pointer::SharedPointer

pub struct SharedPointer<T, P> where
    P: SharedPointerKind
{ /* fields omitted */ }

Pointer to shared data with reference-counting.

The type parameter P is a type constructor of the underlying pointer type, offering a way to abstraction over Rc and Arc smart pointers. This allows you to create data structures where the pointer type is parameterizable, so you can avoid the overhead of Arc when you don’t need to share data across threads.

Example

Declare a data structure with the pointer kind as a type parameter bounded by SharedPointerKind:

use archery::*;

struct KeyValuePair<K, V, P: SharedPointerKind> {
    pub key: SharedPointer<K, P>,
    pub value: SharedPointer<V, P>,
}

impl<K, V, P: SharedPointerKind> KeyValuePair<K, V, P> {
    fn new(key: K, value: V) -> KeyValuePair<K, V, P> {
        KeyValuePair {
            key: SharedPointer::new(key),
            value: SharedPointer::new(value),
        }
    }
}

To use it just plug-in the kind of pointer you want:

let pair: KeyValuePair<_, _, RcK> =
    KeyValuePair::new("António Variações", 1944);

assert_eq!(*pair.value, 1944);

Methods

impl<T, P> SharedPointer<T, P> where
    P: SharedPointerKind
[src]

pub fn new(v: T) -> SharedPointer<T, P>[src]

pub fn try_unwrap(this: SharedPointer<T, P>) -> Result<T, SharedPointer<T, P>>[src]

pub fn get_mut(this: &mut SharedPointer<T, P>) -> Option<&mut T>[src]

pub fn strong_count(this: &Self) -> usize[src]

pub fn ptr_eq<PO: SharedPointerKind>(
    this: &SharedPointer<T, P>,
    other: &SharedPointer<T, PO>
) -> bool
[src]

impl<T, P> SharedPointer<T, P> where
    T: Clone,
    P: SharedPointerKind
[src]

pub fn make_mut(this: &mut SharedPointer<T, P>) -> &mut T[src]

Trait Implementations

impl<T, P> From<T> for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

impl<T, P> From<Box<T>> for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

impl<T, P> Drop for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

impl<T, P> Ord for SharedPointer<T, P> where
    T: Ord,
    P: SharedPointerKind
[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<T, P, PO> PartialOrd<SharedPointer<T, PO>> for SharedPointer<T, P> where
    T: PartialOrd,
    P: SharedPointerKind,
    PO: SharedPointerKind
[src]

impl<T, P, PO> PartialEq<SharedPointer<T, PO>> for SharedPointer<T, P> where
    T: PartialEq,
    P: SharedPointerKind,
    PO: SharedPointerKind
[src]

impl<T, P> Default for SharedPointer<T, P> where
    T: Default,
    P: SharedPointerKind
[src]

impl<T, P> Clone for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

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

Performs copy-assignment from source. Read more

impl<T, P> Eq for SharedPointer<T, P> where
    T: Eq,
    P: SharedPointerKind
[src]

impl<T, P> AsRef<T> for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

impl<T, P> Deref for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

type Target = T

The resulting type after dereferencing.

impl<T, P> Display for SharedPointer<T, P> where
    T: Display,
    P: SharedPointerKind
[src]

impl<T, P> Debug for SharedPointer<T, P> where
    T: Debug,
    P: SharedPointerKind
[src]

impl<T, P> Hash for SharedPointer<T, P> where
    T: Hash,
    P: SharedPointerKind
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T, P> Pointer for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

impl<T, P> Borrow<T> for SharedPointer<T, P> where
    P: SharedPointerKind
[src]

Auto Trait Implementations

impl<T, P> Send for SharedPointer<T, P> where
    P: Send,
    T: Send

impl<T, P> Unpin for SharedPointer<T, P> where
    P: Unpin,
    T: Unpin

impl<T, P> Sync for SharedPointer<T, P> where
    P: Sync,
    T: Sync

impl<T, P> UnwindSafe for SharedPointer<T, P> where
    P: UnwindSafe,
    T: UnwindSafe

impl<T, P> RefUnwindSafe for SharedPointer<T, P> where
    P: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

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

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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> Borrow<T> for T where
    T: ?Sized
[src]

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

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