Skip to content

Commit 51fdc2b

Browse files
committed
Add example of using the indexing operator to HashMap docs
1 parent e8aef7c commit 51fdc2b

File tree

1 file changed

+3
-0
lines changed
  • src/libstd/collections/hash

1 file changed

+3
-0
lines changed

src/libstd/collections/hash/map.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ const DISPLACEMENT_THRESHOLD: usize = 128;
318318
/// }
319319
/// }
320320
///
321+
/// // Look up the value for a key (will panic if the key is not found).
322+
/// println!("Review for Jane: {}", book_reviews["Pride and Prejudice"]);
323+
///
321324
/// // Iterate over everything.
322325
/// for (book, review) in &book_reviews {
323326
/// println!("{}: \"{}\"", book, review);

0 commit comments

Comments
 (0)