diff options
| author | Alexis <a.beingessner@gmail.com> | 2015-03-01 09:42:11 -0500 |
|---|---|---|
| committer | Alexis <a.beingessner@gmail.com> | 2015-03-26 21:36:06 -0400 |
| commit | 93cdf1f2783e3a863929a5ef2032e7de752e4e40 (patch) | |
| tree | 33639adfd0d7c50b42528a196cdeaa6c4ee18845 /src/libstd | |
| parent | 1c35953cf8baa2e721401ba6354f0bd9a9f2abaf (diff) | |
| download | rust-93cdf1f2783e3a863929a5ef2032e7de752e4e40.tar.gz rust-93cdf1f2783e3a863929a5ef2032e7de752e4e40.zip | |
update everything to use Entry defaults
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/mod.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index 8d24f6b1916..b51948c160b 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -307,10 +307,7 @@ //! let message = "she sells sea shells by the sea shore"; //! //! for c in message.chars() { -//! match count.entry(c) { -//! Entry::Vacant(entry) => { entry.insert(1); }, -//! Entry::Occupied(mut entry) => *entry.get_mut() += 1, -//! } +//! *count.entry(c).default(0) += 1; //! } //! //! assert_eq!(count.get(&'s'), Some(&8)); @@ -343,10 +340,7 @@ //! for id in orders.into_iter() { //! // If this is the first time we've seen this customer, initialize them //! // with no blood alcohol. Otherwise, just retrieve them. -//! let person = match blood_alcohol.entry(id) { -//! Entry::Vacant(entry) => entry.insert(Person{id: id, blood_alcohol: 0.0}), -//! Entry::Occupied(entry) => entry.into_mut(), -//! }; +//! let person = blood_alcohol.entry(id).default(Person{id: id, blood_alcohol: 0.0}); //! //! // Reduce their blood alcohol level. It takes time to order and drink a beer! //! person.blood_alcohol *= 0.9; |
