Add missing urls for hash modules

This commit is contained in:
Guillaume Gomez 2016-10-04 18:24:44 +02:00
parent 4a9af010eb
commit 00098bd33b

View File

@ -38,7 +38,9 @@
//! ``` //! ```
//! //!
//! If you need more control over how a value is hashed, you need to implement //! If you need more control over how a value is hashed, you need to implement
//! the `Hash` trait: //! the [`Hash`] trait:
//!
//! [`Hash`]: trait.Hash.html
//! //!
//! ```rust //! ```rust
//! use std::hash::{Hash, Hasher, SipHasher}; //! use std::hash::{Hash, Hasher, SipHasher};
@ -90,7 +92,7 @@ mod sip;
/// The `H` type parameter is an abstract hash state that is used by the `Hash` /// The `H` type parameter is an abstract hash state that is used by the `Hash`
/// to compute the hash. /// to compute the hash.
/// ///
/// If you are also implementing `Eq`, there is an additional property that /// If you are also implementing [`Eq`], there is an additional property that
/// is important: /// is important:
/// ///
/// ```text /// ```text
@ -98,13 +100,13 @@ mod sip;
/// ``` /// ```
/// ///
/// In other words, if two keys are equal, their hashes should also be equal. /// In other words, if two keys are equal, their hashes should also be equal.
/// `HashMap` and `HashSet` both rely on this behavior. /// [`HashMap`] and [`HashSet`] both rely on this behavior.
/// ///
/// ## Derivable /// ## Derivable
/// ///
/// This trait can be used with `#[derive]` if all fields implement `Hash`. /// This trait can be used with `#[derive]` if all fields implement `Hash`.
/// When `derive`d, the resulting hash will be the combination of the values /// When `derive`d, the resulting hash will be the combination of the values
/// from calling `.hash()` on each field. /// from calling [`.hash()`] on each field.
/// ///
/// ## How can I implement `Hash`? /// ## How can I implement `Hash`?
/// ///
@ -127,6 +129,11 @@ mod sip;
/// } /// }
/// } /// }
/// ``` /// ```
///
/// [`Eq`]: ../../std/cmp/trait.Eq.html
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
/// [`.hash()`]: #tymethod.hash
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub trait Hash { pub trait Hash {
/// Feeds this value into the state given, updating the hasher as necessary. /// Feeds this value into the state given, updating the hasher as necessary.
@ -151,35 +158,35 @@ pub trait Hasher {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn finish(&self) -> u64; fn finish(&self) -> u64;
/// Writes some data into this `Hasher` /// Writes some data into this `Hasher`.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn write(&mut self, bytes: &[u8]); fn write(&mut self, bytes: &[u8]);
/// Write a single `u8` into this hasher /// Write a single `u8` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_u8(&mut self, i: u8) { fn write_u8(&mut self, i: u8) {
self.write(&[i]) self.write(&[i])
} }
/// Write a single `u16` into this hasher. /// Writes a single `u16` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_u16(&mut self, i: u16) { fn write_u16(&mut self, i: u16) {
self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) }) self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) })
} }
/// Write a single `u32` into this hasher. /// Writes a single `u32` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_u32(&mut self, i: u32) { fn write_u32(&mut self, i: u32) {
self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) }) self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) })
} }
/// Write a single `u64` into this hasher. /// Writes a single `u64` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_u64(&mut self, i: u64) { fn write_u64(&mut self, i: u64) {
self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) }) self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) })
} }
/// Write a single `usize` into this hasher. /// Writes a single `usize` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_usize(&mut self, i: usize) { fn write_usize(&mut self, i: usize) {
@ -189,31 +196,31 @@ pub trait Hasher {
self.write(bytes); self.write(bytes);
} }
/// Write a single `i8` into this hasher. /// Writes a single `i8` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i8(&mut self, i: i8) { fn write_i8(&mut self, i: i8) {
self.write_u8(i as u8) self.write_u8(i as u8)
} }
/// Write a single `i16` into this hasher. /// Writes a single `i16` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i16(&mut self, i: i16) { fn write_i16(&mut self, i: i16) {
self.write_u16(i as u16) self.write_u16(i as u16)
} }
/// Write a single `i32` into this hasher. /// Writes a single `i32` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i32(&mut self, i: i32) { fn write_i32(&mut self, i: i32) {
self.write_u32(i as u32) self.write_u32(i as u32)
} }
/// Write a single `i64` into this hasher. /// Writes a single `i64` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i64(&mut self, i: i64) { fn write_i64(&mut self, i: i64) {
self.write_u64(i as u64) self.write_u64(i as u64)
} }
/// Write a single `isize` into this hasher. /// Writes a single `isize` into this hasher.
#[inline] #[inline]
#[stable(feature = "hasher_write", since = "1.3.0")] #[stable(feature = "hasher_write", since = "1.3.0")]
fn write_isize(&mut self, i: isize) { fn write_isize(&mut self, i: isize) {