[−][src]Struct tiny_ecs::Persist
Iteration will not always be in order
Implementations
impl<T> Persist<T>
[src]
pub fn with_capacity(capacity: usize) -> Persist<T>
[src]
Allocate with capacity.
This is the only way to create a new persistent vec.
Panics
Will panic if the selected capacity is larger than the ability for
Persist
to internally index in to
pub fn with_capacity_filled_by<F>(capacity: usize, func: F) -> Persist<T> where
F: Fn() -> T,
[src]
F: Fn() -> T,
Allocate with capacity and fill with values produced by a closure
This is a secondary way to create a new persistent vec and is a good way to do so if you know the storage needs to be filled.
Panics
Will panic if the selected capacity is larger than the ability for
Persist
to internally index in to
pub fn from(slice: &[T]) -> Persist<T> where
T: Clone,
[src]
T: Clone,
pub fn len(&self) -> usize
[src]
Returns the actual used length regardless of capacity
pub fn is_empty(&self) -> bool
[src]
pub fn capacity(&self) -> usize
[src]
Returns the storage capacity
pub fn clear(&mut self)
[src]
Clear the storage out while keeping allocated memory
Should not ever panic
pub fn get(&self, index: usize) -> Option<&T>
[src]
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
[src]
pub fn is_index_live(&self, index: usize) -> bool
[src]
Check if there is a value at this index
pub fn push(&mut self, value: T) -> Option<usize>
[src]
Push T
on to storage.
A push is not guaranteed to push in any
particular order if the internal storage has empty locations (typical after
many remove
). For this reason it will return the index pushed to.
Returns None
if there are no free slots left
pub fn insert(&mut self, index: usize, value: T) -> Option<T>
[src]
Insert T
at location. Returns existing value in that location or None
.
Panics
Will panic is the index is out of range
pub fn pop(&mut self) -> Option<T>
[src]
Pop the last value in the Persist
pub fn remove(&mut self, index: usize) -> Option<T>
[src]
Remove the item at this index and return it if it exists. Does not shift elements after it to the left.
pub fn iter(&self) -> Iter<T>
[src]
pub fn iter_mut(&mut self) -> IterMut<T>
[src]
Trait Implementations
impl<T> Debug for Persist<T> where
T: Debug,
[src]
T: Debug,
impl<'_, T> From<&'_ [T]> for Persist<T> where
T: Clone,
[src]
T: Clone,
Total capacity will be set from the length of the slice
impl<'_, T> From<&'_ mut [T]> for Persist<T> where
T: Clone,
[src]
T: Clone,
Total capacity will be set from the length of the slice
Auto Trait Implementations
impl<T> RefUnwindSafe for Persist<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> !Send for Persist<T>
impl<T> !Sync for Persist<T>
impl<T> !Unpin for Persist<T>
impl<T> UnwindSafe for Persist<T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
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,
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, 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.
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>,