[−][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);
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 v = vec![8,9,10usize]; let arr = SmallArray::from_vec(v); assert_eq!(arr.len(), 3);
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: 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<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>,