pub struct ArrayUninit<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> ArrayUninit<T, CAP, S>
impl<T, const CAP: usize, S: Storage> ArrayUninit<T, CAP, S>
Sourcepub fn from_range<I>(iterator: I) -> Result<Self, PartialSpace> ⓘwhere
I: IntoIterator<Item = T>,
pub fn from_range<I>(iterator: I) -> Result<Self, PartialSpace> ⓘ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
PartiallyAdded
if not all elements could be initialized. - Returns
NotEnoughSpace
if the array had no uninitialized elements.
Sourcepub const fn verify_index(
&self,
index: usize,
) -> Result<usize, IndexOutOfBounds> ⓘ
pub const fn verify_index( &self, index: usize, ) -> Result<usize, IndexOutOfBounds> ⓘ
Returns index
back if it’s within the range already initialized.
§Errors
Returns IndexOutOfBounds
if the index is larger than the initialized length.
Sourcepub fn get(&self, index: usize) -> Result<&T, IndexOutOfBounds> ⓘ
pub fn get(&self, index: usize) -> Result<&T, IndexOutOfBounds> ⓘ
Returns a shared reference to an initialized element at a given index.
§Errors
Returns IndexOutOfBounds
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, IndexOutOfBounds> ⓘ
pub fn get_mut(&mut self, index: usize) -> Result<&mut T, IndexOutOfBounds> ⓘ
Returns an exclusive reference to an initialized element at a given index.
§Errors
Returns IndexOutOfBounds
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<(), IndexOutOfBounds> ⓘ
pub fn init_next(&mut self, value: T) -> Result<(), IndexOutOfBounds> ⓘ
Initializes the next uninitialized element with the provided value.
§Errors
Returns IndexOutOfBounds
if the index is larger than the initialized length.
Sourcepub fn init_range<I>(&mut self, values: I) -> Result<usize, PartialSpace> ⓘwhere
I: IntoIterator<Item = T>,
pub fn init_range<I>(&mut self, values: I) -> Result<usize, PartialSpace> ⓘ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
PartiallyAdded
if not all elements could be initialized. - Returns
NotEnoughSpace
if the array had no uninitialized elements.
Sourcepub fn replace(&mut self, index: usize, value: T) -> Result<T, IndexOutOfBounds> ⓘ
pub fn replace(&mut self, index: usize, value: T) -> Result<T, IndexOutOfBounds> ⓘ
Replaces the value at a given index with a new value and returns the old value.
§Errors
Returns IndexOutOfBounds
if the index is not within the range of initialized elements.
Sourcepub fn swap(
&mut self,
index1: usize,
index2: usize,
) -> Result<(), IndexOutOfBounds> ⓘ
pub fn swap( &mut self, index1: usize, index2: usize, ) -> Result<(), IndexOutOfBounds> ⓘ
Swaps the values at two indices.
§Errors
Returns IndexOutOfBounds
if either index is not within the range of initialized elements.
Trait Implementations§
Auto Trait Implementations§
impl<T, const CAP: usize, S> Freeze for ArrayUninit<T, CAP, S>
impl<T, const CAP: usize, S> RefUnwindSafe for ArrayUninit<T, CAP, S>
impl<T, const CAP: usize, S> Send for ArrayUninit<T, CAP, S>
impl<T, const CAP: usize, S> Sync for ArrayUninit<T, CAP, S>
impl<T, const CAP: usize, S> Unpin for ArrayUninit<T, CAP, S>
impl<T, const CAP: usize, S> UnwindSafe for ArrayUninit<T, CAP, S>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
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> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.