[−][src]Struct dynamic_array::array::Array
A dynamically-allocated array of fixed size.
Example
use dynamic_array::SmallArray; let mut arr = SmallArray::<u32>::zeroed(9); assert!(!arr.is_empty()); // can be freely dereferenced assert_eq!(arr[3], 0); arr[7] = 8; assert_eq!(arr[7], 8); let mut arr2 = arr.clone(); assert_ne!(arr2[3],4); arr[2] = 4; arr2[3] = 4; assert_eq!(arr[2],4); assert_eq!(arr2[3],4); // can also be freely iterated for x in arr.iter_mut() { *x += 1; } assert_eq!(arr[2], 5);
Implementations
impl<T, Len: Copy + Into<usize> + TryFrom<usize>> Array<T, Len>
[src]
pub fn zeroed(len: Len) -> Self
[src]
Creates a zeroed Array
with length len
.
pub fn from_raw(raw: *mut T, len: Len) -> Self
[src]
Constructs a new Array
from a raw pointer.
After calling this function the pointer is owned by the resulting Array
.
pub fn from_vec(v: Vec<T>) -> Self where
<Len as TryFrom<usize>>::Error: Debug,
[src]
<Len as TryFrom<usize>>::Error: Debug,
Constructs a new Array
from a given Vec
.
Example
use dynamic_array::SmallArray; let mut v = vec![8,9,10usize]; v.reserve(1000); let arr = SmallArray::from_vec(v); assert_eq!(arr.len(), 3);
pub fn into_vec(self) -> Vec<T>
[src]
Constructs a Vec
from Self
.
Example
use dynamic_array::SmallArray; let arr = SmallArray::<usize>::zeroed(5); let v: Vec<usize> = arr.into_vec(); assert_eq!(v.len(), 5); assert_eq!(v[3], 0);
pub fn len(&self) -> usize
[src]
The length of the array
Example
use dynamic_array::SmallArray; let arr = SmallArray::<()>::zeroed(42); assert_eq!(arr.len(), 42);
pub fn is_empty(&self) -> bool
[src]
Trait Implementations
impl<T: Clone, Len: Copy + Into<usize> + TryFrom<usize>> Clone for Array<T, Len>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug, Len: Copy + Into<usize> + TryFrom<usize>> Debug for Array<T, Len>
[src]
impl<T, Len: Copy + Into<usize> + TryFrom<usize>> Deref for Array<T, Len>
[src]
impl<T, Len: Copy + Into<usize> + TryFrom<usize>> DerefMut for Array<T, Len>
[src]
impl<T, Len: Copy + Into<usize> + TryFrom<usize>> Drop for Array<T, Len>
[src]
impl<T, Len: Copy + Into<usize> + TryFrom<usize>> IntoIterator for Array<T, Len>
[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, T, Len: Copy + Into<usize> + TryFrom<usize>> IntoIterator for &'t Array<T, Len>
[src]
type Item = &'t T
The type of the elements being iterated over.
type IntoIter = Iter<'t, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'t, T>
[src]
impl<'t, T, Len: Copy + Into<usize> + TryFrom<usize>> IntoIterator for &'t mut Array<T, Len>
[src]
type Item = &'t mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'t, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'t, T>
[src]
impl<T: Send, Len: Copy + Into<usize> + TryFrom<usize>> Send for Array<T, Len>
[src]
impl<T: Sync, Len: Copy + Into<usize> + TryFrom<usize>> Sync for Array<T, Len>
[src]
Auto Trait Implementations
impl<T, Len> RefUnwindSafe for Array<T, Len> where
Len: RefUnwindSafe,
T: RefUnwindSafe,
Len: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, Len> Unpin for Array<T, Len> where
Len: Unpin,
Len: Unpin,
impl<T, Len> UnwindSafe for Array<T, Len> where
Len: UnwindSafe,
T: RefUnwindSafe,
Len: UnwindSafe,
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,
pub 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?
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,