Struct SafeArray

Source
pub struct SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,
{ /* private fields */ }
Expand description

Safe, generic interface to BaseArray.

Uses length information to guarrantee memory safety, and excludes operations that cannot be performed safely from its API.

Trait Implementations§

Source§

impl<E, L, P> Clone for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>, E: Clone, L: Clone,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E, L, P> Container for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn len(&self) -> usize

Get the size of the container.
Source§

impl<E, L, P> CopyMap<usize, E> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

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

Get a reference to a value from this map. Read more
Source§

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

Get a mutable reference to a value from this map. Read more
Source§

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

Inserts a key-value pair into the map. Read more
Source§

impl<E, L, P> Debug for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>, E: Debug, L: Debug,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E, L, P> DefaultLabelledArray<E, L> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>, E: Default,

Source§

fn with_len(label: L, len: usize) -> Self

Create a new array, initialized to default values.
Source§

impl<E, L, P> Drop for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<E, L, P> Index<usize> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

type Output = E

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &E

Performs the indexing (container[index]) operation. Read more
Source§

impl<E, L, P> IndexMut<usize> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn index_mut(&mut self, idx: usize) -> &mut E

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, E, L, P> IntoIterator for &'a SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

type Item = &'a E

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, E>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, E, L, P> IntoIterator for &'a mut SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

type Item = &'a mut E

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, E>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<E, L, P> IntoIterator for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

type Item = E

The type of the elements being iterated over.
Source§

type IntoIter = BaseArrayIter<E, L, P>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<E, L, P> LabelledArray<E, L> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn with_label<F>(label: L, len: usize, func: F) -> Self
where F: FnMut(&mut L, usize) -> E,

Create a new array, with values initialized using a provided function, and label initialized to a provided value.
Source§

fn get_label(&self) -> &L

Get a reference to the label.
Source§

unsafe fn get_unchecked(&self, idx: usize) -> &E

Get a reference to the element at a specified index. Implementations of this method shouldn’t do any safety checks.
Source§

impl<E, L, P> LabelledArrayMut<E, L> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn get_label_mut(&mut self) -> &mut L

Get mutable reference to the label.
Source§

unsafe fn get_mut_unchecked(&mut self, idx: usize) -> &mut E

Get a mutable reference to the element at a specified index. Implementations of this method shouldn’t do any safety checks.
Source§

impl<E, P> MakeArray<E> for SafeArray<E, (), P>
where P: SafeArrayPtr<E, ()>,

Source§

fn new<F>(len: usize, func: F) -> Self
where F: FnMut(usize) -> E,

Create a new array, with values initialized using a provided function.
Source§

impl<E, L, P> SliceArray<E> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn as_slice(&self) -> &[E]

Returns a reference to a slice into the elements of this array.
Source§

impl<E, L, P> SliceArrayMut<E> for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>,

Source§

fn as_slice_mut(&mut self) -> &mut [E]

Returns a mutable reference to a slice into the elements of this array.
Source§

impl<E, L, P> Send for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>, E: Send, L: Send,

Source§

impl<E, L, P> Sync for SafeArray<E, L, P>
where P: SafeArrayPtr<E, L>, E: Sync, L: Sync,

Auto Trait Implementations§

§

impl<E, L, P> Freeze for SafeArray<E, L, P>
where P: Freeze,

§

impl<E, L, P> RefUnwindSafe for SafeArray<E, L, P>

§

impl<E, L, P> Unpin for SafeArray<E, L, P>
where P: Unpin, E: Unpin, L: Unpin,

§

impl<E, L, P> UnwindSafe for SafeArray<E, L, P>
where P: UnwindSafe, E: UnwindSafe, L: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.