Skip to content

Commit 579d19b

Browse files
committed
Use hash_one to simplify some other doctests
1 parent 63d2819 commit 579d19b

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

library/alloc/src/vec/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -2411,18 +2411,13 @@ impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
24112411
/// as required by the `core::borrow::Borrow` implementation.
24122412
///
24132413
/// ```
2414-
/// use std::hash::{BuildHasher, Hash, Hasher};
2415-
///
2416-
/// fn hash_of(x: impl Hash, b: &impl BuildHasher) -> u64 {
2417-
/// let mut h = b.build_hasher();
2418-
/// x.hash(&mut h);
2419-
/// h.finish()
2420-
/// }
2414+
/// #![feature(build_hasher_simple_hash_one)]
2415+
/// use std::hash::BuildHasher;
24212416
///
24222417
/// let b = std::collections::hash_map::RandomState::new();
24232418
/// let v: Vec<u8> = vec![0xa8, 0x3c, 0x09];
24242419
/// let s: &[u8] = &[0xa8, 0x3c, 0x09];
2425-
/// assert_eq!(hash_of(v, &b), hash_of(s, &b));
2420+
/// assert_eq!(b.hash_one(v), b.hash_one(s));
24262421
/// ```
24272422
#[stable(feature = "rust1", since = "1.0.0")]
24282423
impl<T: Hash, A: Allocator> Hash for Vec<T, A> {

library/core/src/array/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,13 @@ impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
143143
/// as required by the `Borrow` implementation.
144144
///
145145
/// ```
146-
/// use std::hash::{BuildHasher, Hash, Hasher};
147-
///
148-
/// fn hash_of(x: impl Hash, b: &impl BuildHasher) -> u64 {
149-
/// let mut h = b.build_hasher();
150-
/// x.hash(&mut h);
151-
/// h.finish()
152-
/// }
146+
/// #![feature(build_hasher_simple_hash_one)]
147+
/// use std::hash::BuildHasher;
153148
///
154149
/// let b = std::collections::hash_map::RandomState::new();
155150
/// let a: [u8; 3] = [0xa8, 0x3c, 0x09];
156151
/// let s: &[u8] = &[0xa8, 0x3c, 0x09];
157-
/// assert_eq!(hash_of(a, &b), hash_of(s, &b));
152+
/// assert_eq!(b.hash_one(a), b.hash_one(s));
158153
/// ```
159154
#[stable(feature = "rust1", since = "1.0.0")]
160155
impl<T: Hash, const N: usize> Hash for [T; N] {

0 commit comments

Comments
 (0)