pub struct BlobVec { /* private fields */ }
Expand description
A flat, type-erased data storage type
Used to densely store homogeneous ECS data.
Implementations
sourceimpl BlobVec
impl BlobVec
pub fn new(
item_layout: Layout,
drop: unsafe fn(*mut u8),
capacity: usize
) -> BlobVec
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn reserve_exact(&mut self, additional: usize)
sourcepub unsafe fn initialize_unchecked(&mut self, index: usize, value: *mut u8)
pub unsafe fn initialize_unchecked(&mut self, index: usize, value: *mut u8)
Safety
- index must be in bounds
- the memory in the
BlobVec
starting at indexindex
, of a size matching thisBlobVec
’sitem_layout
, must have been previously allocated, but not initialized yet - the memory at
*value
must be previously initialized with an item matching thisBlobVec
’sitem_layout
- the item that was stored in
*value
is left logically uninitialised/moved out of after calling this function, and as such should not be used or dropped by the caller.
sourcepub unsafe fn replace_unchecked(&mut self, index: usize, value: *mut u8)
pub unsafe fn replace_unchecked(&mut self, index: usize, value: *mut u8)
Safety
- index must be in-bounds
- the memory in the
BlobVec
starting at indexindex
, of a size matching thisBlobVec
’sitem_layout
, must have been previously initialized with an item matching thisBlobVec
’sitem_layout
- the memory at
*value
must also be previously initialized with an item matching thisBlobVec
’sitem_layout
- the item that was stored in
*value
is left logically uninitialised/moved out of after calling this function, and as such should not be used or dropped by the caller.
sourcepub unsafe fn push_uninit(&mut self) -> usize
pub unsafe fn push_uninit(&mut self) -> usize
Increases the length by one (and grows the vec if needed) with uninitialized memory and returns the index
Safety
the newly allocated space must be immediately populated with a valid value
sourcepub unsafe fn set_len(&mut self, len: usize)
pub unsafe fn set_len(&mut self, len: usize)
Safety
len
must be <= capacity
. if length is decreased, “out of bounds” items must be dropped.
Newly added items must be immediately populated with valid values and length must be
increased. For better unwind safety, call BlobVec::set_len
after populating a new
value.
sourcepub unsafe fn swap_remove_and_forget_unchecked(
&mut self,
index: usize
) -> *mut u8
pub unsafe fn swap_remove_and_forget_unchecked(
&mut self,
index: usize
) -> *mut u8
Performs a “swap remove” at the given index
, which removes the item at index
and moves
the last item in the BlobVec
to index
(if index
is not the last item). It is the
caller’s responsibility to drop the returned pointer, if that is desirable.
Safety
It is the caller’s responsibility to ensure that index
is < self.len()
Callers should only access the returned pointer immediately after calling this function.
sourcepub unsafe fn swap_remove_and_drop_unchecked(&mut self, index: usize)
pub unsafe fn swap_remove_and_drop_unchecked(&mut self, index: usize)
Safety
index must be in-bounds
sourcepub unsafe fn get_unchecked(&self, index: usize) -> *mut u8
pub unsafe fn get_unchecked(&self, index: usize) -> *mut u8
Safety
It is the caller’s responsibility to ensure that index
is < self.len()
pub fn clear(&mut self)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BlobVec
impl !Send for BlobVec
impl !Sync for BlobVec
impl Unpin for BlobVec
impl UnwindSafe for BlobVec
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more