]> git.lizzy.rs Git - rust.git/commitdiff
Use `hash_one` to simplify some other doctests
authorScott McMurray <scottmcm@users.noreply.github.com>
Thu, 24 Jun 2021 08:30:08 +0000 (01:30 -0700)
committerScott McMurray <scottmcm@users.noreply.github.com>
Thu, 24 Jun 2021 08:30:48 +0000 (01:30 -0700)
library/alloc/src/vec/mod.rs
library/core/src/array/mod.rs

index f3a47cba759e6bb9d4d0a1e53e61c97d643108d8..4ac28b8308e73126a111d8a21da78c0a9f349e50 100644 (file)
@@ -2411,18 +2411,13 @@ fn clone_from(&mut self, other: &Self) {
 /// as required by the `core::borrow::Borrow` implementation.
 ///
 /// ```
-/// use std::hash::{BuildHasher, Hash, Hasher};
-///
-/// fn hash_of(x: impl Hash, b: &impl BuildHasher) -> u64 {
-///     let mut h = b.build_hasher();
-///     x.hash(&mut h);
-///     h.finish()
-/// }
+/// #![feature(build_hasher_simple_hash_one)]
+/// use std::hash::BuildHasher;
 ///
 /// let b = std::collections::hash_map::RandomState::new();
 /// let v: Vec<u8> = vec![0xa8, 0x3c, 0x09];
 /// let s: &[u8] = &[0xa8, 0x3c, 0x09];
-/// assert_eq!(hash_of(v, &b), hash_of(s, &b));
+/// assert_eq!(b.hash_one(v), b.hash_one(s));
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Hash, A: Allocator> Hash for Vec<T, A> {
index f44e22b3dbd7c5d27ddb114ceb9b037a4a1db373..030b42a53d05d757f0b35953ce9f268fed89e8a7 100644 (file)
@@ -143,18 +143,13 @@ fn borrow_mut(&mut self) -> &mut [T] {
 /// as required by the `Borrow` implementation.
 ///
 /// ```
-/// use std::hash::{BuildHasher, Hash, Hasher};
-///
-/// fn hash_of(x: impl Hash, b: &impl BuildHasher) -> u64 {
-///     let mut h = b.build_hasher();
-///     x.hash(&mut h);
-///     h.finish()
-/// }
+/// #![feature(build_hasher_simple_hash_one)]
+/// use std::hash::BuildHasher;
 ///
 /// let b = std::collections::hash_map::RandomState::new();
 /// let a: [u8; 3] = [0xa8, 0x3c, 0x09];
 /// let s: &[u8] = &[0xa8, 0x3c, 0x09];
-/// assert_eq!(hash_of(a, &b), hash_of(s, &b));
+/// assert_eq!(b.hash_one(a), b.hash_one(s));
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Hash, const N: usize> Hash for [T; N] {