[][src]Struct dynvec::RawDynVec

pub struct RawDynVec<R: Region<Header>> { /* fields omitted */ }

A dynamic vector, able to store any kind of data.

Implementations

impl<R: Region<Header>> RawDynVec<R>[src]

pub fn with_region(region: R) -> Self[src]

Creates a new RawDynVec with the given region.

pub fn count(&self) -> usize[src]

Returns the number of items this vector stores.

pub fn try_insert<T>(&mut self, item: T) -> Result<Handle<T>, T>[src]

Tries to insert a T into the vector and returns a Handle to this T. If the T cannot be allocated, it gets returned as the error.

pub fn clear(&mut self)[src]

Clears the whole vector, leaving it empty.

pub fn insert<T>(&mut self, item: T) -> Handle<T>[src]

Inserts a T into the vector and returns a Handle to this T.

Panics

This function panics if the T could not be allocated.

pub unsafe fn insert_raw(
    &mut self,
    layout: Layout,
    drop_fn: Option<fn(_: *mut u8)>
) -> Result<RawHandle, ()>
[src]

Allocates memory as described by the given layout. If the allocation is a success, a raw handle to the allocation is returned. In this case, it is up to the caller to initialize the allocated value because the vector now assumes it is initialized.

Safety

  • The drop_fn function must cause the object to be dropped.
  • The allocated data must get initialized before it being dropped.

pub fn remove<T>(&mut self, handle: Handle<T>) -> Result<T, ()>[src]

Tries to remove the T located by the given handle. If the handle was invalid, Err(()) is returned.

pub fn remove_raw(&mut self, handle: RawHandle) -> Result<(), ()>[src]

Tries to remove an item out of the vector. If the handle was invalid Err(()) is returned.

As the handle is raw, the item cannot be returned. But it is still dropped properly.

pub fn get_ptr<T>(&self, handle: Handle<T>) -> *const T[src]

Gets a pointer to the data located by the given handle.

Safety

If the null pointer is returned, the handle was invalid.

pub fn get_mut_ptr<T>(&self, handle: Handle<T>) -> *mut T[src]

Gets a pointer to the data located by the given handle.

Safety

If the null pointer is returned, the handle was invalid.

pub fn get_ptr_raw(&mut self, handle: RawHandle) -> *const u8[src]

Gets a pointer to the data located by the given handle.

Safety

If the null pointer is returned, the handle was invalid.

pub fn get_mut_ptr_raw(&mut self, handle: RawHandle) -> *mut u8[src]

Gets a pointer to the data located by the given handle.

Safety

If the null pointer is returned, the handle was invalid.

pub fn try_get<T>(&self, handle: Handle<T>) -> Option<&T>[src]

Tries to get a reference to the data located by the given handle.

pub fn try_get_mut<T>(&mut self, handle: Handle<T>) -> Option<&mut T>[src]

Tries to get a reference to the data located by the given handle.

pub fn get<T>(&self, handle: Handle<T>) -> &T[src]

Gets a reference to the data located by the given handle.

Panics

If the handle is valid, this function panics.

pub fn get_mut<T>(&mut self, handle: Handle<T>) -> &mut T[src]

Gets a reference to the data located by the given handle.

Panics

If the handle is valid, this function panics.

impl RawDynVec<Chunks<Header>>[src]

pub fn new() -> Self[src]

Allocates a new DynVec with a minimal chunk size of 1024 bytes.

pub fn with_chunk_size(min_chunk_size: usize) -> Self[src]

Creates a new DynVec with the given chunk size. Note that chunks can be allocated with a larger size if large objects need to be inserted.

pub fn with_chunks(min_chunk_size: usize, chunk_count: usize) -> Self[src]

Creates a new DynVec with the given chunk size and chunk count. This function allocates chunk_count chunks in advance.

Trait Implementations

impl<R: Default + Region<Header>> Default for RawDynVec<R>[src]

impl<R: Region<Header>> Drop for RawDynVec<R>[src]

impl<R: Region<Header>, T> Index<Handle<T>> for RawDynVec<R>[src]

type Output = T

The returned type after indexing.

impl<R: Region<Header>, T> IndexMut<Handle<T>> for RawDynVec<R>[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for RawDynVec<R> where
    R: RefUnwindSafe
[src]

impl<R> Send for RawDynVec<R> where
    R: Send
[src]

impl<R> Sync for RawDynVec<R> where
    R: Sync
[src]

impl<R> Unpin for RawDynVec<R> where
    R: Unpin
[src]

impl<R> UnwindSafe for RawDynVec<R> where
    R: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.