Struct devela::data::collections::UninitArray
source · pub struct UninitArray<T, const CAP: usize, S: Storage = Bare> { /* private fields */ }unsafe_array only.Expand description
A static array allowing uninitialized elements.
Implementations§
source§impl<T, const CAP: usize, S: Storage> UninitArray<T, CAP, S>
impl<T, const CAP: usize, S: Storage> UninitArray<T, CAP, S>
sourcepub fn from_range<I>(iterator: I) -> Result<Self>where
I: IntoIterator<Item = T>,
pub fn from_range<I>(iterator: I) -> Result<Self>where
I: IntoIterator<Item = T>,
Initializes the array from an iterator until it’s either full or the iterator is exhausted.
§Returns
- Returns a new array initialized with the elements from the
iterator. - Returns
PartiallyAddedif not all elements could be initialized. - Returns
NotEnoughSpaceif the array had no uninitialized elements.
sourcepub const fn verify_index(&self, index: usize) -> Result<usize>
pub const fn verify_index(&self, index: usize) -> Result<usize>
Returns index back if it’s within the range already initialized.
§Errors
Returns OutOfBounds if the index is larger than the initialized length.
sourcepub fn get(&self, index: usize) -> Result<&T>
pub fn get(&self, index: usize) -> Result<&T>
Returns a shared reference to an initialized element at a given index.
§Errors
Returns OutOfBounds if the index is larger than the initialized length.
or if the element at that index is not initialized.
sourcepub fn get_mut(&mut self, index: usize) -> Result<&mut T>
pub fn get_mut(&mut self, index: usize) -> Result<&mut T>
Returns an exclusive reference to an initialized element at a given index.
§Errors
Returns OutOfBounds if the index is larger than the initialized length.
or if the element at that index is not initialized.
sourcepub fn init_next(&mut self, value: T) -> Result<()>
pub fn init_next(&mut self, value: T) -> Result<()>
Initializes the next uninitialized element with the provided value.
§Errors
Returns OutOfBounds if the index is larger than the initialized length.
sourcepub fn init_range<I>(&mut self, values: I) -> Result<usize>where
I: IntoIterator<Item = T>,
pub fn init_range<I>(&mut self, values: I) -> Result<usize>where
I: IntoIterator<Item = T>,
Initializes elements from an iterator
Starts at the last initialized element, continues until either the array is full or the iterator is exhausted.
§Returns
- Returns the number of elements initialized.
- Returns
PartiallyAddedif not all elements could be initialized. - Returns
NotEnoughSpaceif the array had no uninitialized elements.
Trait Implementations§
Auto Trait Implementations§
impl<T, const CAP: usize, S> Freeze for UninitArray<T, CAP, S>
impl<T, const CAP: usize, S> RefUnwindSafe for UninitArray<T, CAP, S>
impl<T, const CAP: usize, S> Send for UninitArray<T, CAP, S>
impl<T, const CAP: usize, S> Sync for UninitArray<T, CAP, S>
impl<T, const CAP: usize, S> Unpin for UninitArray<T, CAP, S>
impl<T, const CAP: usize, S> UnwindSafe for UninitArray<T, CAP, S>
Blanket Implementations§
source§impl<T> Also for T
impl<T> Also for T
source§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> ByteSize for T
impl<T> ByteSize for T
source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
source§impl<T> ExtAny for Twhere
T: Any,
impl<T> ExtAny for Twhere
T: Any,
source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
source§impl<T> Mem for Twhere
T: ?Sized,
impl<T> Mem for Twhere
T: ?Sized,
source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters.source§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor.source§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
self with other, returning the previous value of self.source§fn mem_take(&mut self) -> Selfwhere
Self: Default,
fn mem_take(&mut self) -> Selfwhere
Self: Default,
self with its default value, returning the previous value of self.source§fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
self and other without deinitializing either one.source§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice only.