[][src]Struct indexed_map::IndexedMap

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

An indexed map

TODO: replace inner methods with full copy of HashMap API

Methods

impl<T> IndexedMap<T>[src]

pub fn new() -> IndexedMap<T>[src]

Create a new `IndexedMap'

Examples

use indexed_map::IndexedMap;
let mut foo = IndexedMap::new();
let bar = foo.insert("bar");
println!("{:?}", foo);

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

Insert an item, creating a new unique key, and return the key

Examples

use indexed_map::IndexedMap;

// create an empty `IndexedMap`, just like `HashMap`
let mut fruits = IndexedMap::new();

// insert some values and store their keys for later use
let apple = fruits.insert("Apple");
let orange = fruits.insert("Orange");
let pear = fruits.insert("Pear");

// list the values we've inserted
for fruit in fruits.inner().values() {
    println!("{}", fruit);
}

// access using unique keys
assert_eq!("Apple", *fruits.inner().get(&apple).unwrap());
assert_eq!("Orange", *fruits.inner().get(&orange).unwrap());
assert_eq!("Pear", *fruits.inner().get(&pear).unwrap());

pub fn inner(&self) -> &HashMap<usize, T>[src]

Access the underlying HashMap

pub fn inner_mut(&mut self) -> &mut HashMap<usize, T>[src]

Mutably access the underlying HashMap

pub fn into_inner(self) -> HashMap<usize, T>[src]

Unwrap the IndexedMap to return the underlying HashMap

Trait Implementations

impl<T: Clone> Clone for IndexedMap<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 IndexedMap<T>[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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