Skip to content

Commit 5d19e63

Browse files
committed
Documentation cleanups from libstd HashMap
1 parent f6b2ef8 commit 5d19e63

File tree

3 files changed

+13
-40
lines changed

3 files changed

+13
-40
lines changed

benches/bench.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
10-
111
#![feature(test)]
122

133
extern crate hashbrown;

src/map.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
10-
111
use self::Entry::*;
122

133
use core::borrow::Borrow;
@@ -101,6 +91,9 @@ pub use fx::FxHashBuilder as DefaultHashBuilder;
10191
/// }
10292
/// }
10393
///
94+
/// // Look up the value for a key (will panic if the key is not found).
95+
/// println!("Review for Jane: {}", book_reviews["Pride and Prejudice"]);
96+
///
10497
/// // Iterate over everything.
10598
/// for (book, review) in &book_reviews {
10699
/// println!("{}: \"{}\"", book, review);
@@ -136,7 +129,7 @@ pub use fx::FxHashBuilder as DefaultHashBuilder;
136129
/// *stat += random_stat_buff();
137130
/// ```
138131
///
139-
/// The easiest way to use `HashMap` with a custom type as key is to derive [`Eq`] and [`Hash`].
132+
/// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`].
140133
/// We must also derive [`PartialEq`].
141134
///
142135
/// [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
@@ -2788,7 +2781,7 @@ mod test_map {
27882781
for i in 1..1001 {
27892782
assert!(m.insert(i, i).is_none());
27902783

2791-
for j in 1..i + 1 {
2784+
for j in 1..=i {
27922785
let r = m.get(&j);
27932786
assert_eq!(r, Some(&j));
27942787
}
@@ -2807,7 +2800,7 @@ mod test_map {
28072800
for i in 1..1001 {
28082801
assert!(m.remove(&i).is_some());
28092802

2810-
for j in 1..i + 1 {
2803+
for j in 1..=i {
28112804
assert!(!m.contains_key(&j));
28122805
}
28132806

src/set.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
10-
111
use core::borrow::Borrow;
122
use core::fmt;
133
use core::hash::{BuildHasher, Hash};
@@ -197,7 +187,7 @@ where
197187
}
198188
}
199189

200-
/// Creates an empty `HashSet` with with the specified capacity, using
190+
/// Creates an empty `HashSet` with the specified capacity, using
201191
/// `hasher` to hash the keys.
202192
///
203193
/// The hash set will be able to hold at least `capacity` elements without
@@ -371,7 +361,7 @@ where
371361
}
372362

373363
/// Visits the values representing the difference,
374-
/// i.e. the values that are in `self` but not in `other`.
364+
/// i.e., the values that are in `self` but not in `other`.
375365
///
376366
/// # Examples
377367
///
@@ -402,7 +392,7 @@ where
402392
}
403393

404394
/// Visits the values representing the symmetric difference,
405-
/// i.e. the values that are in `self` or in `other` but not in both.
395+
/// i.e., the values that are in `self` or in `other` but not in both.
406396
///
407397
/// # Examples
408398
///
@@ -433,7 +423,7 @@ where
433423
}
434424

435425
/// Visits the values representing the intersection,
436-
/// i.e. the values that are both in `self` and `other`.
426+
/// i.e., the values that are both in `self` and `other`.
437427
///
438428
/// # Examples
439429
///
@@ -459,7 +449,7 @@ where
459449
}
460450

461451
/// Visits the values representing the union,
462-
/// i.e. all the values in `self` or `other`, without duplicates.
452+
/// i.e., all the values in `self` or `other`, without duplicates.
463453
///
464454
/// # Examples
465455
///
@@ -634,7 +624,7 @@ where
634624
}
635625

636626
/// Returns `true` if the set is a subset of another,
637-
/// i.e. `other` contains at least all the values in `self`.
627+
/// i.e., `other` contains at least all the values in `self`.
638628
///
639629
/// # Examples
640630
///
@@ -655,7 +645,7 @@ where
655645
}
656646

657647
/// Returns `true` if the set is a superset of another,
658-
/// i.e. `self` contains at least all the values in `other`.
648+
/// i.e., `self` contains at least all the values in `other`.
659649
///
660650
/// # Examples
661651
///

0 commit comments

Comments
 (0)