pub struct IndexedMap<T> { /* private fields */ }
Expand description
An indexed map
TODO: replace inner
methods with full copy of HashMap
API
Implementations§
Source§impl<T> IndexedMap<T>
impl<T> IndexedMap<T>
Sourcepub fn new() -> IndexedMap<T>
pub fn new() -> IndexedMap<T>
Create a new `IndexedMap’
§Examples
use indexed_map::IndexedMap;
let mut foo = IndexedMap::new();
let bar = foo.insert("bar");
println!("{:?}", foo);
Sourcepub fn insert(&mut self, value: T) -> usize
pub fn insert(&mut self, value: T) -> usize
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());
Sourcepub fn into_inner(self) -> HashMap<usize, T>
pub fn into_inner(self) -> HashMap<usize, T>
Unwrap the IndexedMap
to return the underlying HashMap
Trait Implementations§
Source§impl<T: Clone> Clone for IndexedMap<T>
impl<T: Clone> Clone for IndexedMap<T>
Source§fn clone(&self) -> IndexedMap<T>
fn clone(&self) -> IndexedMap<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for IndexedMap<T>
impl<T> RefUnwindSafe for IndexedMap<T>where
T: RefUnwindSafe,
impl<T> Send for IndexedMap<T>where
T: Send,
impl<T> Sync for IndexedMap<T>where
T: Sync,
impl<T> Unpin for IndexedMap<T>where
T: Unpin,
impl<T> UnwindSafe for IndexedMap<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more