[][src]Struct malloc_array::HeapArray

pub struct HeapArray<T> {
    pub drop_check: bool,
    // some fields omitted
}

Array created by libc malloc() and dropped by libc free().

Fields

drop_check: bool

Call drop() on sub-elements when dropping the array. This is not needed for types that implement Copy.

Implementations

impl<T> HeapArray<T>[src]

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

Size of memory of this instance in bytes.

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

Number of elements in this instance.

pub fn initialise<'a>(&'a mut self) -> InitIter<'a, T>[src]

Create an iterator for safely setting potentially uninitialised values within the instance.

pub unsafe fn set_memory(&mut self, value: u8)[src]

Set each byte to a value.

pub fn new(size: usize) -> Self[src]

Creates a new HeapArray<T> from zeroed memory.

pub fn new_uninit(size: usize) -> Self[src]

Creates a new HeapArray<T> from uninitialised memory.

pub fn resize(self, size: usize) -> Self[src]

Consumes the instance, returning a new instance after calling realloc() on the underlying memory.

pub fn new_repeat(initial: T, size: usize) -> Self where
    T: Copy
[src]

Creates a new HeapArray<T> from an initial element and a size.

pub fn new_range<U>(initial: U, size: usize) -> Self where
    T: Copy,
    U: AsRef<[T]>, 
[src]

Creates a new HeapArray<T> from a range of elements and a size, repeating if needed.

pub fn as_slice(&self) -> &[T][src]

As an immutable slice of T.

pub fn as_slice_mut(&mut self) -> &mut [T][src]

As a mutable slice of T.

pub fn as_ptr(&self) -> *const T[src]

As immutable raw pointer.

pub fn as_ptr_mut(&mut self) -> *mut T[src]

As mutable raw pointer.

pub fn memory(&self) -> &[u8][src]

An immutable slice of the memory.

pub unsafe fn memory_mut(&mut self) -> &mut [u8][src]

A mutable slice of the memory.

pub fn into_raw_parts(self) -> (*mut T, usize)[src]

Consumes the instance. Returns a raw pointer and the number of elements.

pub unsafe fn from_raw_parts(ptr: *mut T, size: usize) -> Self[src]

Create a HeapArray<T> from a raw pointer and a number of elements.

pub fn free(self)[src]

Consumes the instance. Frees the memory without dropping the items.

pub fn into_slice(self, slice: &mut [T])[src]

Consumes the instance, moving all elements into a slice.

pub fn from_boxed_slice(bx: Box<[T]>) -> Self[src]

Coerce or clone memory from a boxed slice.

pub fn into_boxed_slice(self) -> Box<[T]>[src]

Coerce or clone memory into a boxed slice.

pub unsafe fn reinterpret<U>(self) -> HeapArray<U>[src]

Reinterpret the memory of this instance into an insteance of a different type

Panics

If U cannot fit into T.

pub fn reinterpret_ref<U>(&self) -> &[U][src]

Reinterpret the memory of this instance into an immutable slice of a different type.

Panics

If U cannot fit into T.

pub unsafe fn reinterpret_mut<U>(&mut self) -> &mut [U][src]

Reinterpret the memory of this instance into a mutable slice of a different type.

Panics

If U cannot fit into T.

pub fn iter<'a>(&'a self) -> Iter<'a, T>[src]

Immutable slice iterator for this instance

pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T>[src]

Mutable slice iterator for this instance

pub fn replace_and_forget(&mut self, index: usize, value: T)[src]

Replace the element at index with value, and forget the old one. Useful with new_uninit().

pub unsafe fn clone_mem(&self) -> Self[src]

Clone the memory to a new instance.

pub fn leak(self) -> &'static mut [T][src]

Leak the memory to a static slice reference.

pub unsafe fn memory_from_bytes<U: AsRef<[u8]>>(&mut self, from: U) -> usize[src]

Copy memory in from a slice of bytes.

pub unsafe fn memory_from_raw_bytes(
    &mut self,
    from: *const u8,
    size: usize
) -> usize
[src]

Copy memory in from a pointer to bytes.

pub unsafe fn memory_from_slice<U: AsRef<[T]>>(&mut self, from: U) -> usize[src]

Copy memory in from a raw pointer.

pub unsafe fn memory_from_raw(&mut self, from: *const T, size: usize) -> usize[src]

Copy memory in from a raw pointer.

pub unsafe fn from_raw_copied(from: *const T, size: usize) -> Self[src]

Create a new instance with memory copied from a raw pointer.

pub unsafe fn from_slice_copied<U: AsRef<[T]>>(from: U) -> Self where
    T: Copy
[src]

Create a new instance with memory copied from a slice.

pub unsafe fn from_raw_bytes(from: *const u8, size: usize) -> Self[src]

Create a new instance with memory bytes copied from a raw pointer.

pub unsafe fn from_bytes<U: AsRef<[u8]>>(from: U) -> Self[src]

Create a new instance with memory bytes copied from a slice.

Trait Implementations

impl<T> AsMut<[T]> for HeapArray<T>[src]

impl<T> AsRef<[T]> for HeapArray<T>[src]

impl<T> Borrow<[T]> for HeapArray<T>[src]

impl<T> BorrowMut<[T]> for HeapArray<T>[src]

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

impl<T> Debug for HeapArray<T> where
    T: Debug
[src]

impl<T> Deref for HeapArray<T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T> DerefMut for HeapArray<T>[src]

impl<T> Drop for HeapArray<T>[src]

impl<T> Eq for HeapArray<T> where
    T: Eq
[src]

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

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

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

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

impl<T> Hash for HeapArray<T> where
    T: Hash
[src]

impl<T, I> Index<I> for HeapArray<T> where
    I: SliceIndex<[T]>, 
[src]

type Output = <I as SliceIndex<[T]>>::Output

The returned type after indexing.

impl<T, I> IndexMut<I> for HeapArray<T> where
    I: SliceIndex<[T]>, 
[src]

impl<T> IntoIterator for HeapArray<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<T, U> PartialEq<U> for HeapArray<T> where
    T: PartialEq,
    U: AsRef<[T]>, 
[src]

impl<T> Send for HeapArray<T> where
    T: Send
[src]

impl<T> Sync for HeapArray<T> where
    T: Sync
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for HeapArray<T> where
    T: RefUnwindSafe

impl<T> Unpin for HeapArray<T>

impl<T> UnwindSafe for HeapArray<T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

type Owned = T

The resulting type after obtaining ownership.

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.