diff options
| author | bors <bors@rust-lang.org> | 2018-12-07 08:46:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-07 08:46:45 +0000 |
| commit | fc84f5f837a3e1b9b9bc992dd603d3d968502288 (patch) | |
| tree | 9e64c02fb9f8084d26a6a743c62ac54626e549d3 /src/libcore | |
| parent | 15a2607863fded7570cacfc7825702dde5a4234c (diff) | |
| parent | a40aa45980f45e26a227a889a69b54bcfcd68eba (diff) | |
Auto merge of #56581 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #56000 (Add Armv8-M Mainline targets) - #56250 (Introduce ptr::hash for references) - #56434 (Improve query cycle errors for parallel queries) - #56516 (Replace usages of `..i + 1` ranges with `..=i`.) - #56555 (Send textual profile data to stderr, not stdout) - #56561 (Fix bug in from_key_hashed_nocheck) - #56574 (Fix a stutter in the docs for slice::exact_chunks) Failed merges: r? @ghost
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ptr.rs | 30 | ||||
| -rw-r--r-- | src/libcore/slice/mod.rs | 3 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0387708033b..8630dd402ef 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2516,6 +2516,36 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool { a == b } +/// Hash the raw pointer address behind a reference, rather than the value +/// it points to. +/// +/// # Examples +/// +/// ``` +/// #![feature(ptr_hash)] +/// use std::collections::hash_map::DefaultHasher; +/// use std::hash::{Hash, Hasher}; +/// use std::ptr; +/// +/// let five = 5; +/// let five_ref = &five; +/// +/// let mut hasher = DefaultHasher::new(); +/// ptr::hash(five_ref, &mut hasher); +/// let actual = hasher.finish(); +/// +/// let mut hasher = DefaultHasher::new(); +/// (five_ref as *const i32).hash(&mut hasher); +/// let expected = hasher.finish(); +/// +/// assert_eq!(actual, expected); +/// ``` +#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56286")] +pub fn hash<T, S: hash::Hasher>(hashee: *const T, into: &mut S) { + use hash::Hash; + hashee.hash(into); +} + // Impls for function pointers macro_rules! fnptr_impls_safety_abi { ($FnTy: ty, $($Arg: ident),*) => { diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8c55a16f3c8..5b57dcabb8d 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -702,8 +702,7 @@ impl<T> [T] { /// resulting code better than in the case of [`chunks`]. /// /// See [`chunks`] for a variant of this iterator that also returns the remainder as a smaller - /// chunk, and [`rchunks_exact`] for the same iterator but starting at the end of the slice of - /// the slice. + /// chunk, and [`rchunks_exact`] for the same iterator but starting at the end of the slice. /// /// # Panics /// |
