Skip to content

Commit

Permalink
Documentation cleanups from libstd HashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Jan 14, 2019
1 parent f6b2ef8 commit 5d19e63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 40 deletions.
10 changes: 0 additions & 10 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(test)]

extern crate hashbrown;
Expand Down
19 changes: 6 additions & 13 deletions src/map.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use self::Entry::*;

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

for j in 1..i + 1 {
for j in 1..=i {
let r = m.get(&j);
assert_eq!(r, Some(&j));
}
Expand All @@ -2807,7 +2800,7 @@ mod test_map {
for i in 1..1001 {
assert!(m.remove(&i).is_some());

for j in 1..i + 1 {
for j in 1..=i {
assert!(!m.contains_key(&j));
}

Expand Down
24 changes: 7 additions & 17 deletions src/set.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use core::borrow::Borrow;
use core::fmt;
use core::hash::{BuildHasher, Hash};
Expand Down Expand Up @@ -197,7 +187,7 @@ where
}
}

/// Creates an empty `HashSet` with with the specified capacity, using
/// Creates an empty `HashSet` with the specified capacity, using
/// `hasher` to hash the keys.
///
/// The hash set will be able to hold at least `capacity` elements without
Expand Down Expand Up @@ -371,7 +361,7 @@ where
}

/// Visits the values representing the difference,
/// i.e. the values that are in `self` but not in `other`.
/// i.e., the values that are in `self` but not in `other`.
///
/// # Examples
///
Expand Down Expand Up @@ -402,7 +392,7 @@ where
}

/// Visits the values representing the symmetric difference,
/// i.e. the values that are in `self` or in `other` but not in both.
/// i.e., the values that are in `self` or in `other` but not in both.
///
/// # Examples
///
Expand Down Expand Up @@ -433,7 +423,7 @@ where
}

/// Visits the values representing the intersection,
/// i.e. the values that are both in `self` and `other`.
/// i.e., the values that are both in `self` and `other`.
///
/// # Examples
///
Expand All @@ -459,7 +449,7 @@ where
}

/// Visits the values representing the union,
/// i.e. all the values in `self` or `other`, without duplicates.
/// i.e., all the values in `self` or `other`, without duplicates.
///
/// # Examples
///
Expand Down Expand Up @@ -634,7 +624,7 @@ where
}

/// Returns `true` if the set is a subset of another,
/// i.e. `other` contains at least all the values in `self`.
/// i.e., `other` contains at least all the values in `self`.
///
/// # Examples
///
Expand All @@ -655,7 +645,7 @@ where
}

/// Returns `true` if the set is a superset of another,
/// i.e. `self` contains at least all the values in `other`.
/// i.e., `self` contains at least all the values in `other`.
///
/// # Examples
///
Expand Down

0 comments on commit 5d19e63

Please sign in to comment.