Skip to content

Commit c199d25

Browse files
committed
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`
1 parent 44855a4 commit c199d25

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/libcore/hash/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,17 @@ pub trait BuildHasher {
285285
fn build_hasher(&self) -> Self::Hasher;
286286
}
287287

288-
/// The `BuildHasherDefault` structure is used in scenarios where one has a
289-
/// type that implements [`Hasher`] and [`Default`], but needs that type to
290-
/// implement [`BuildHasher`].
288+
/// Used to create a default [`BuildHasher`] instance for types that implement
289+
/// [`Hasher`] and [`Default`].
291290
///
292-
/// This structure is zero-sized and does not need construction.
291+
/// `BuildHasherDefault<H>` can be used when a type `H` implements [`Hasher`] and
292+
/// [`Default`], and you need a corresponding [`BuildHasher`] instance, but none is
293+
/// defined.
294+
///
295+
/// Any `BuildHasherDefault` is [zero-sized]. It can be created with
296+
/// [`default`][method.Default]. When using `BuildHasherDefault` with [`HashMap`] or
297+
/// [`HashSet`], this doesn't need to be done, since they implement appropriate
298+
/// [`Default`] instances themselves.
293299
///
294300
/// # Examples
295301
///
@@ -322,8 +328,11 @@ pub trait BuildHasher {
322328
///
323329
/// [`BuildHasher`]: trait.BuildHasher.html
324330
/// [`Default`]: ../default/trait.Default.html
331+
/// [method.default]: #method.default
325332
/// [`Hasher`]: trait.Hasher.html
326333
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
334+
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
335+
/// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts
327336
#[stable(since = "1.7.0", feature = "build_hasher")]
328337
pub struct BuildHasherDefault<H>(marker::PhantomData<H>);
329338

0 commit comments

Comments
 (0)