about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlukaramu <lukaramu@gmail.com>2017-04-06 21:59:08 +0200
committerlukaramu <lukaramu@gmail.com>2017-04-06 21:59:08 +0200
commitc199d253867085dae44f6946d7085a991abe17c8 (patch)
treeecbff29553bfee42f67c0d3cbf5269131550dac3
parent44855a4cef3e83c76c386fdcf034447a8ee128e4 (diff)
downloadrust-c199d253867085dae44f6946d7085a991abe17c8.tar.gz
rust-c199d253867085dae44f6946d7085a991abe17c8.zip
rephrased std::hash::BuildHasherDefault docs
Part of #29357.
* split summary and explanation more clearly
* added link to nomicon for "zero-sized"
* "does not need construction" -> say how it can be created, and that it
  doesn't need to be done with `HashMap` or `HashSet`
-rw-r--r--src/libcore/hash/mod.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs
index 756d472eca8..0d34aeb7cb7 100644
--- a/src/libcore/hash/mod.rs
+++ b/src/libcore/hash/mod.rs
@@ -285,11 +285,17 @@ pub trait BuildHasher {
     fn build_hasher(&self) -> Self::Hasher;
 }
 
-/// The `BuildHasherDefault` structure is used in scenarios where one has a
-/// type that implements [`Hasher`] and [`Default`], but needs that type to
-/// implement [`BuildHasher`].
+/// Used to create a default [`BuildHasher`] instance for types that implement
+/// [`Hasher`] and [`Default`].
 ///
-/// This structure is zero-sized and does not need construction.
+/// `BuildHasherDefault<H>` can be used when a type `H` implements [`Hasher`] and
+/// [`Default`], and you need a corresponding [`BuildHasher`] instance, but none is
+/// defined.
+///
+/// Any `BuildHasherDefault` is [zero-sized]. It can be created with
+/// [`default`][method.Default]. When using `BuildHasherDefault` with [`HashMap`] or
+/// [`HashSet`], this doesn't need to be done, since they implement appropriate
+/// [`Default`] instances themselves.
 ///
 /// # Examples
 ///
@@ -322,8 +328,11 @@ pub trait BuildHasher {
 ///
 /// [`BuildHasher`]: trait.BuildHasher.html
 /// [`Default`]: ../default/trait.Default.html
+/// [method.default]: #method.default
 /// [`Hasher`]: trait.Hasher.html
 /// [`HashMap`]: ../../std/collections/struct.HashMap.html
+/// [`HashSet`]: ../../std/collections/struct.HashSet.html
+/// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts
 #[stable(since = "1.7.0", feature = "build_hasher")]
 pub struct BuildHasherDefault<H>(marker::PhantomData<H>);