Skip to content

Commit da74d89

Browse files
committed
---
yaml --- r: 94787 b: refs/heads/try c: 8715736 h: refs/heads/master i: 94785: 37dcb5b 94783: 48675ab v: v3
1 parent 3e220b0 commit da74d89

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 2ca0b58f60e55afdffc68a8aef24704ad2a2a2e3
5+
refs/heads/try: 87157361170ef5cd0f8a7a307d19d2343ed3618f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/hashmap.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,45 @@
1212
//!
1313
//! The tables use a keyed hash with new random keys generated for each container, so the ordering
1414
//! of a set of keys in a hash table is randomized.
15+
//!
16+
//! # Example
17+
//!
18+
//! ```rust
19+
//! use std::hashmap::HashMap;
20+
//!
21+
//! // type inference lets us omit an explicit type signature (which
22+
//! // would be `HashMap<&str, &str>` in this example).
23+
//! let mut book_reviews = HashMap::new();
24+
//!
25+
//! // review some books.
26+
//! book_reviews.insert("Adventures of Hucklebury Fin", "My favorite book.");
27+
//! book_reviews.insert("Grimms' Fairy Tales", "Masterpiece.");
28+
//! book_reviews.insert("Pride and Prejudice", "Very enjoyable.");
29+
//! book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
30+
//!
31+
//! // check for a specific one.
32+
//! if !book_reviews.contains_key(& &"Les Misérables") {
33+
//! println!("We've got {} reviews, but Les Misérables ain't one.",
34+
//! book_reviews.len());
35+
//! }
36+
//!
37+
//! // oops, this review has a lot of spelling mistakes, let's delete it.
38+
//! book_reviews.remove(& &"The Adventures of Sherlock Holmes");
39+
//!
40+
//! // look up the values associated with some keys.
41+
//! let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
42+
//! for book in to_find.iter() {
43+
//! match book_reviews.find(book) {
44+
//! Some(review) => println!("{}: {}", *book, *review),
45+
//! None => println!("{} is unreviewed.", *book)
46+
//! }
47+
//! }
48+
//!
49+
//! // iterate over everything.
50+
//! for (book, review) in book_reviews.iter() {
51+
//! println!("{}: \"{}\"", *book, *review);
52+
//! }
53+
//! ```
1554
1655
use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
1756
use clone::Clone;

0 commit comments

Comments
 (0)