1.56.0  Â· [ source ](../../src/std/collections/hash/map.rs.html#1358-1374) Â§

###  impl<K, V, const N: [ usize ](../primitive.usize.html) > [ From
](../convert/trait.From.html "trait std::convert::From") <[ [ (K, V)
](../primitive.tuple.html) ; [ N ](../primitive.array.html) ]> for [ HashMap
](hash_map/struct.HashMap.html "struct std::collections::hash_map::HashMap")
<K, V, [ RandomState ](hash_map/struct.RandomState.html "struct
std::collections::hash_map::RandomState") >

where K: [ Eq ](../cmp/trait.Eq.html "trait std::cmp::Eq") \+ [ Hash
](../hash/trait.Hash.html "trait std::hash::Hash") ,

[ source ](../../src/std/collections/hash/map.rs.html#1371-1373) Â§

####  fn [ from ](../convert/trait.From.html#tymethod.from) (arr: [ [ (K, V)
](../primitive.tuple.html) ; [ N ](../primitive.array.html) ]) -> Self

#####  Â§  Examples

    
    
    use std::collections::HashMap;
    
    let map1 = HashMap::from([(1, 2), (3, 4)]);
    let map2: HashMap<_, _> = [(1, 2), (3, 4)].into();
    assert_eq!(map1, map2);

[ Run ](https://play.rust-
lang.org/?code=%23!%5Ballow\(unused\)%5D%0Afn+main\(\)+%7B%0Ause+std::collections::HashMap;%0A%0Alet+map1+=+HashMap::from\(%5B\(1,+2\),+\(3,+4\)%5D\);%0Alet+map2:+HashMap%3C_,+_%3E+=+%5B\(1,+2\),+\(3,+4\)%5D.into\(\);%0Aassert_eq!\(map1,+map2\);%0A%7D&edition=2021)

[ source ](../../src/std/collections/hash/map.rs.html#3120-3130) Â§

###  impl<K, V, S> [ FromIterator ](../iter/trait.FromIterator.html "trait
std::iter::FromIterator") < [ (K, V) ](../primitive.tuple.html) > for [
HashMap ](hash_map/struct.HashMap.html "struct
std::collections::hash_map::HashMap") <K, V, S>

where K: [ Eq ](../cmp/trait.Eq.html "trait std::cmp::Eq") \+ [ Hash
](../hash/trait.Hash.html "trait std::hash::Hash") , S: [ BuildHasher
](../hash/trait.BuildHasher.html "trait std::hash::BuildHasher") \+ [ Default
](../default/trait.Default.html "trait std::default::Default") ,

[ source ](../../src/std/collections/hash/map.rs.html#3125-3129) Â§

####  fn [ from_iter ](../iter/trait.FromIterator.html#tymethod.from_iter) <T:
[ IntoIterator ](../iter/trait.IntoIterator.html "trait
std::iter::IntoIterator") <Item = [ (K, V) ](../primitive.tuple.html) >>(iter:
T) -> [ HashMap ](hash_map/struct.HashMap.html "struct
std::collections::hash_map::HashMap") <K, V, S>

Creates a value from an iterator. [ Read more
](../iter/trait.FromIterator.html#tymethod.from_iter)

[ source ](../../src/std/collections/hash/map.rs.html#1326-1343) Â§

###  impl<K, Q, V, S> [ Index ](../ops/trait.Index.html "trait
std::ops::Index") < [ &Q ](../primitive.reference.html) > for [ HashMap
](hash_map/struct.HashMap.html "struct std::collections::hash_map::HashMap")
<K, V, S>

where K: [ Eq ](../cmp/trait.Eq.html "trait std::cmp::Eq") \+ [ Hash
](../hash/trait.Hash.html "trait std::hash::Hash") \+ [ Borrow
](../borrow/trait.Borrow.html "trait std::borrow::Borrow") <Q>, Q: [ Eq
](../cmp/trait.Eq.html "trait std::cmp::Eq") \+ [ Hash
](../hash/trait.Hash.html "trait std::hash::Hash") \+ ? [ Sized
](../marker/trait.Sized.html "trait std::marker::Sized") , S: [ BuildHasher
](../hash/trait.BuildHasher.html "trait std::hash::BuildHasher") ,

[ source ](../../src/std/collections/hash/map.rs.html#1340-1342) Â§

####  fn [ index ](../ops/trait.Index.html#tymethod.index) (&self, key: [ &Q
](../primitive.reference.html) ) -> [ &V ](../primitive.reference.html)

Returns a reference to the value corresponding to the supplied key.

#####  Â§  Panics

Panics if the key is not present in the ` HashMap ` .

Â§

####  type [ Output ](../ops/trait.Index.html#associatedtype.Output) = V

The returned type after indexing.

[ source ](../../src/std/collections/hash/map.rs.html#2173-2182) Â§

###  impl<'a, K, V, S> [ IntoIterator ](../iter/trait.IntoIterator.html "trait
std::iter::IntoIterator") for &'a [ HashMap ](hash_map/struct.HashMap.html
"struct std::collections::hash_map::HashMap") <K, V, S>

Â§

####  type [ Item ](../iter/trait.IntoIterator.html#associatedtype.Item) = ( [
&