[−][src]Struct malloc_array::HeapArray
Array created by libc malloc()
and dropped by libc free()
.
Fields
drop_check: bool
Call drop()
on sub-elements when drop
ping 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]
T: Copy,
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]
T: Copy,
U: AsRef<[T]>,
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]
&mut self,
from: *const u8,
size: usize
) -> usize
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]
T: Copy,
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]
fn borrow_mut(&mut self) -> &mut [T]
[src]
impl<T> Clone for HeapArray<T> where
T: Clone,
[src]
T: Clone,
impl<T> Debug for HeapArray<T> where
T: Debug,
[src]
T: Debug,
impl<T> Deref for HeapArray<T>
[src]
impl<T> DerefMut for HeapArray<T>
[src]
impl<T> Drop for HeapArray<T>
[src]
impl<T> Eq for HeapArray<T> where
T: Eq,
[src]
T: Eq,
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]
T: Hash,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, I> Index<I> for HeapArray<T> where
I: SliceIndex<[T]>,
[src]
I: SliceIndex<[T]>,
type Output = <I as SliceIndex<[T]>>::Output
The returned type after indexing.
fn index(&self, index: I) -> &Self::Output
[src]
impl<T, I> IndexMut<I> for HeapArray<T> where
I: SliceIndex<[T]>,
[src]
I: SliceIndex<[T]>,
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?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T, U> PartialEq<U> for HeapArray<T> where
T: PartialEq,
U: AsRef<[T]>,
[src]
T: PartialEq,
U: AsRef<[T]>,
impl<T> Send for HeapArray<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for HeapArray<T> where
T: Sync,
[src]
T: Sync,
Auto Trait Implementations
impl<T> RefUnwindSafe for HeapArray<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for HeapArray<T>
impl<T> UnwindSafe for HeapArray<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,