[][src]Struct genmap::GenMap

pub struct GenMap<T> { /* fields omitted */ }

A collection of T's referred to by Handle's. When you add an object to the GenMap it will return a Handle, and you can look that item up by that Handle. You can also remove the item, which makes any old Handle's to it become invalid and attempting to get it will return None.

Methods

impl<T> GenMap<T>[src]

pub fn with_capacity(capacity: usize) -> Self[src]

Create a new empty GenMap with enough memory to accomodate the given number of items without reallocating.

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

Insert the element into the map and return a handle referring to it.

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

Returns a reference to the item if the handle is valid, or None otherwise.

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

Returns a mutable reference to the item if the handle is valid, or None otherwise.

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

Removes the referenced item from the map, returning it. Returns None if the handle is stale.

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

Number of items in the map.

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

The total number of items the map has free memory to contain.

Important traits for Iterator<'_, T>
pub fn iter(&self) -> Iterator<T>[src]

Trait Implementations

impl<T: Default> Default for GenMap<T>[src]

impl<T: Clone> Clone for GenMap<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for GenMap<T>[src]

Auto Trait Implementations

impl<T> Send for GenMap<T> where
    T: Send

impl<T> Unpin for GenMap<T> where
    T: Unpin

impl<T> Sync for GenMap<T> where
    T: Sync

impl<T> UnwindSafe for GenMap<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for GenMap<T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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