diff options
| author | bors <bors@rust-lang.org> | 2016-09-28 15:03:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-28 15:03:26 -0700 |
| commit | 86affcdf6c622278a89b73bb7f1b8ac00e970888 (patch) | |
| tree | f8f361e0f1dd7ed5980297531f829b13fd0314bc /src/libstd | |
| parent | f17b1e03dfb5df1754a7c68bda439ed9c0b51de4 (diff) | |
| parent | ac82eaaafef1a85c266acfcf659fe62405f1c99f (diff) | |
| download | rust-86affcdf6c622278a89b73bb7f1b8ac00e970888.tar.gz rust-86affcdf6c622278a89b73bb7f1b8ac00e970888.zip | |
Auto merge of #36805 - jonathandturner:rollup, r=jonathandturner
Rollup of 11 pull requests - Successful merges: #36376, #36672, #36740, #36757, #36765, #36769, #36782, #36783, #36784, #36795, #36796 - Failed merges:
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 16 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 14 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 29a79631535..35f5641679a 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -335,6 +335,22 @@ fn test_resize_policy() { /// println!("{:?} has {} hp", viking, health); /// } /// ``` +/// +/// A HashMap with fixed list of elements can be initialized from an array: +/// +/// ``` +/// use std::collections::HashMap; +/// +/// fn main() { +/// let timber_resources: HashMap<&str, i32> = +/// [("Norway", 100), +/// ("Denmark", 50), +/// ("Iceland", 10)] +/// .iter().cloned().collect(); +/// // use the values stored in map +/// } +/// ``` + #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct HashMap<K, V, S = RandomState> { diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index a5089543980..cb8393ed075 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -98,6 +98,20 @@ use super::map::{self, HashMap, Keys, RandomState}; /// println!("{:?}", x); /// } /// ``` +/// +/// HashSet with fixed list of elements can be initialized from an array: +/// +/// ``` +/// use std::collections::HashSet; +/// +/// fn main() { +/// let viking_names: HashSet<&str> = +/// [ "Einar", "Olaf", "Harald" ].iter().cloned().collect(); +/// // use the values stored in the set +/// } +/// ``` + + #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct HashSet<T, S = RandomState> { |
