Type Definition ndarray::CowArray[][src]

type CowArray<'a, A, D> = ArrayBase<CowRepr<'a, A>, D>;

An array with copy-on-write behavior.

An CowArray represents either a uniquely owned array or a view of an array. The 'a corresponds to the lifetime of the view variant.

This type is analogous to std::borrow::Cow. If a CowArray instance is the immutable view variant, then calling a method for mutating elements in the array will cause it to be converted into the owned variant (by cloning all the elements) before the modification is performed.

Array views have all the methods of an array (see ArrayBase).

See also ArcArray, which also provides copy-on-write behavior but has a reference-counted pointer to the data instead of either a view or a uniquely owned copy.

Implementations

impl<'a, A, D> CowArray<'a, A, D> where
    D: Dimension
[src]

Methods specific to CowArray.

See also all methods for ArrayBase

pub fn is_view(&self) -> bool[src]

Returns true iff the array is the view (borrowed) variant.

pub fn is_owned(&self) -> bool[src]

Returns true iff the array is the owned variant.

Trait Implementations

impl<'a, A, D> From<ArrayBase<OwnedRepr<A>, D>> for CowArray<'a, A, D> where
    D: Dimension
[src]

impl<'a, A, D> From<ArrayBase<ViewRepr<&'a A>, D>> for CowArray<'a, A, D> where
    D: Dimension
[src]