Use hash_one
to simplify some other doctests
This commit is contained in:
parent
63d28192da
commit
579d19bc6a
2 changed files with 6 additions and 16 deletions
|
@ -2411,18 +2411,13 @@ impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
|
||||||
/// as required by the `core::borrow::Borrow` implementation.
|
/// as required by the `core::borrow::Borrow` implementation.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::hash::{BuildHasher, Hash, Hasher};
|
/// #![feature(build_hasher_simple_hash_one)]
|
||||||
///
|
/// use std::hash::BuildHasher;
|
||||||
/// fn hash_of(x: impl Hash, b: &impl BuildHasher) -> u64 {
|
|
||||||
/// let mut h = b.build_hasher();
|
|
||||||
/// x.hash(&mut h);
|
|
||||||
/// h.finish()
|
|
||||||
/// }
|
|
||||||
///
|
///
|
||||||
/// let b = std::collections::hash_map::RandomState::new();
|
/// let b = std::collections::hash_map::RandomState::new();
|
||||||
/// let v: Vec<u8> = vec![0xa8, 0x3c, 0x09];
|
/// let v: Vec<u8> = vec![0xa8, 0x3c, 0x09];
|
||||||
/// let s: &[u8] = &[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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: Hash, A: Allocator> Hash for Vec<T, A> {
|
impl<T: Hash, A: Allocator> Hash for Vec<T, A> {
|
||||||
|
|
|
@ -143,18 +143,13 @@ impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
|
||||||
/// as required by the `Borrow` implementation.
|
/// as required by the `Borrow` implementation.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::hash::{BuildHasher, Hash, Hasher};
|
/// #![feature(build_hasher_simple_hash_one)]
|
||||||
///
|
/// use std::hash::BuildHasher;
|
||||||
/// fn hash_of(x: impl Hash, b: &impl BuildHasher) -> u64 {
|
|
||||||
/// let mut h = b.build_hasher();
|
|
||||||
/// x.hash(&mut h);
|
|
||||||
/// h.finish()
|
|
||||||
/// }
|
|
||||||
///
|
///
|
||||||
/// let b = std::collections::hash_map::RandomState::new();
|
/// let b = std::collections::hash_map::RandomState::new();
|
||||||
/// let a: [u8; 3] = [0xa8, 0x3c, 0x09];
|
/// let a: [u8; 3] = [0xa8, 0x3c, 0x09];
|
||||||
/// let s: &[u8] = &[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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: Hash, const N: usize> Hash for [T; N] {
|
impl<T: Hash, const N: usize> Hash for [T; N] {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue