diff --git a/src/iter.rs b/src/iter.rs index ce50e739..4db2b186 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -10,7 +10,7 @@ use hashbrown::hash_map; use std::collections::hash_map::RandomState; use std::sync::Arc; -/// Iterator over a DashMap yielding key value pairs. +/// Iterator over a `DashMap` yielding key value pairs. /// /// # Examples /// @@ -101,7 +101,7 @@ type GuardIterMut<'a, K, V, S> = ( hash_map::IterMut<'a, K, SharedValue>, ); -/// Iterator over a DashMap yielding immutable references. +/// Iterator over a `DashMap` yielding immutable references. /// /// # Examples /// @@ -184,7 +184,7 @@ impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iter } } -/// Iterator over a DashMap yielding mutable references. +/// Iterator over a `DashMap` yielding mutable references. /// /// # Examples /// diff --git a/src/lib.rs b/src/lib.rs index 34e5d8ba..01c405f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,14 +74,14 @@ fn ncb(shard_amount: usize) -> usize { shard_amount.trailing_zeros() as usize } -/// DashMap is an implementation of a concurrent associative array/hashmap in Rust. +/// `DashMap` is an implementation of a concurrent associative array/hashmap in Rust. /// -/// DashMap tries to implement an easy to use API similar to `std::collections::HashMap` +/// `DashMap` tries to implement an easy to use API similar to `std::collections::HashMap` /// with some slight changes to handle concurrency. /// -/// DashMap tries to be very simple to use and to be a direct replacement for `RwLock>`. +/// `DashMap` tries to be very simple to use and to be a direct replacement for `RwLock>`. /// To accomplish this, all methods take `&self` instead of modifying methods taking `&mut self`. -/// This allows you to put a DashMap in an `Arc` and share it between threads while being able to modify it. +/// This allows you to put a `DashMap` in an `Arc` and share it between threads while being able to modify it. /// /// Documentation mentioning locking behaviour acts in the reference frame of the calling thread. /// This means that it is safe to ignore it across multiple threads. @@ -120,7 +120,7 @@ where } impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap { - /// Creates a new DashMap with a capacity of 0. + /// Creates a new `DashMap` with a capacity of 0. /// /// # Examples /// @@ -134,7 +134,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap { DashMap::with_hasher(RandomState::default()) } - /// Creates a new DashMap with a specified starting capacity. + /// Creates a new `DashMap` with a specified starting capacity. /// /// # Examples /// @@ -149,10 +149,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap { DashMap::with_capacity_and_hasher(capacity, RandomState::default()) } - /// Creates a new DashMap with a specified shard amount + /// Creates a new `DashMap` with a specified shard amount /// - /// shard_amount should greater than 0 and be a power of two. - /// If a shard_amount which is not a power of two is provided, the function will panic. + /// `shard_amount` should greater than 0 and be a power of two. + /// If a `shard_amount` which is not a power of two is provided, the function will panic. /// /// # Examples /// @@ -167,10 +167,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap { Self::with_capacity_and_hasher_and_shard_amount(0, RandomState::default(), shard_amount) } - /// Creates a new DashMap with a specified capacity and shard amount. + /// Creates a new `DashMap` with a specified capacity and shard amount. /// - /// shard_amount should greater than 0 and be a power of two. - /// If a shard_amount which is not a power of two is provided, the function will panic. + /// `shard_amount` should greater than 0 and be a power of two. + /// If a `shard_amount` which is not a power of two is provided, the function will panic. /// /// # Examples /// @@ -196,7 +196,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { ReadOnlyView::new(self) } - /// Creates a new DashMap with a capacity of 0 and the provided hasher. + /// Creates a new `DashMap` with a capacity of 0 and the provided hasher. /// /// # Examples /// @@ -212,7 +212,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { Self::with_capacity_and_hasher(0, hasher) } - /// Creates a new DashMap with a specified starting capacity and hasher. + /// Creates a new `DashMap` with a specified starting capacity and hasher. /// /// # Examples /// @@ -229,10 +229,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { Self::with_capacity_and_hasher_and_shard_amount(capacity, hasher, default_shard_amount()) } - /// Creates a new DashMap with a specified hasher and shard amount + /// Creates a new `DashMap` with a specified hasher and shard amount /// - /// shard_amount should be greater than 0 and a power of two. - /// If a shard_amount which is not a power of two is provided, the function will panic. + /// `shard_amount` should be greater than 0 and a power of two. + /// If a `shard_amount` which is not a power of two is provided, the function will panic. /// /// # Examples /// @@ -249,10 +249,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { Self::with_capacity_and_hasher_and_shard_amount(0, hasher, shard_amount) } - /// Creates a new DashMap with a specified starting capacity, hasher and shard_amount. + /// Creates a new `DashMap` with a specified starting capacity, hasher and `shard_amount`. /// - /// shard_amount should greater than 0 and be a power of two. - /// If a shard_amount which is not a power of two is provided, the function will panic. + /// `shard_amount` should greater than 0 and be a power of two. + /// If a `shard_amount` which is not a power of two is provided, the function will panic. /// /// # Examples /// @@ -293,7 +293,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { } /// Hash a given item to produce a usize. - /// Uses the provided or default HashBuilder. + /// Uses the provided or default `HashBuilder`. pub fn hash_usize(&self, item: &T) -> usize { let mut hasher = self.hasher.build_hasher(); @@ -517,7 +517,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { self._remove_if_mut(key, f) } - /// Creates an iterator over a DashMap yielding immutable references. + /// Creates an iterator over a `DashMap` yielding immutable references. /// /// **Locking behaviour:** May deadlock if called when holding a mutable reference into the map. /// @@ -534,7 +534,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { self._iter() } - /// Iterator over a DashMap yielding mutable references. + /// Iterator over a `DashMap` yielding mutable references. /// /// **Locking behaviour:** May deadlock if called when holding any sort of reference into the map. /// @@ -596,7 +596,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { } /// Get an immutable reference to an entry in the map, if the shard is not locked. - /// If the shard is locked, the function will return [TryResult::Locked]. + /// If the shard is locked, the function will return [`TryResult::Locked`]. /// /// # Examples /// @@ -623,7 +623,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { } /// Get a mutable reference to an entry in the map, if the shard is not locked. - /// If the shard is locked, the function will return [TryResult::Locked]. + /// If the shard is locked, the function will return [`TryResult::Locked`]. /// /// # Examples /// diff --git a/src/mapref/entry.rs b/src/mapref/entry.rs index e9e6b913..d4e04579 100644 --- a/src/mapref/entry.rs +++ b/src/mapref/entry.rs @@ -94,7 +94,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> Entry<'a, K, V, S> { } } - /// Sets the value of the entry, and returns an OccupiedEntry. + /// Sets the value of the entry, and returns an `OccupiedEntry`. /// /// If you are not interested in the occupied entry, /// consider [`insert`] as it doesn't need to clone the key. @@ -147,7 +147,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> VacantEntry<'a, K, V, S> { } } - /// Sets the value of the entry with the VacantEntry’s key, and returns an OccupiedEntry. + /// Sets the value of the entry with the VacantEntry’s key, and returns an `OccupiedEntry`. pub fn insert_entry(mut self, value: V) -> OccupiedEntry<'a, K, V, S> where K: Clone, diff --git a/src/mapref/one.rs b/src/mapref/one.rs index fd385309..a23c443b 100644 --- a/src/mapref/one.rs +++ b/src/mapref/one.rs @@ -140,7 +140,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> RefMut<'a, K, V, S> { where F: FnOnce(&mut V) -> Option<&mut T>, { - let v = match f(unsafe { &mut *(self.v as *mut _) }) { + let v = match f(unsafe { &mut *self.v.cast() }) { Some(v) => v, None => return Err(self), }; @@ -297,7 +297,7 @@ impl<'a, K: Eq + Hash, V, T, S: BuildHasher> MappedRefMut<'a, K, V, T, S> { where F: FnOnce(&mut T) -> Option<&mut T2>, { - let v = match f(unsafe { &mut *(self.v as *mut _) }) { + let v = match f(unsafe { &mut *self.v.cast() }) { Some(v) => v, None => return Err(self), }; diff --git a/src/set.rs b/src/set.rs index 1a561770..22333fd2 100644 --- a/src/set.rs +++ b/src/set.rs @@ -12,7 +12,7 @@ use core::hash::{BuildHasher, Hash}; use core::iter::FromIterator; use std::collections::hash_map::RandomState; -/// DashSet is a thin wrapper around [`DashMap`] using `()` as the value type. It uses +/// `DashSet` is a thin wrapper around [`DashMap`] using `()` as the value type. It uses /// methods and types which are more convenient to work with on a set. /// /// [`DashMap`]: struct.DashMap.html @@ -49,7 +49,7 @@ where } impl<'a, K: 'a + Eq + Hash> DashSet { - /// Creates a new DashSet with a capacity of 0. + /// Creates a new `DashSet` with a capacity of 0. /// /// # Examples /// @@ -63,7 +63,7 @@ impl<'a, K: 'a + Eq + Hash> DashSet { Self::with_hasher(RandomState::default()) } - /// Creates a new DashMap with a specified starting capacity. + /// Creates a new `DashMap` with a specified starting capacity. /// /// # Examples /// @@ -80,7 +80,7 @@ impl<'a, K: 'a + Eq + Hash> DashSet { } impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet { - /// Creates a new DashMap with a capacity of 0 and the provided hasher. + /// Creates a new `DashMap` with a capacity of 0 and the provided hasher. /// /// # Examples /// @@ -96,7 +96,7 @@ impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet { Self::with_capacity_and_hasher(0, hasher) } - /// Creates a new DashMap with a specified starting capacity and hasher. + /// Creates a new `DashMap` with a specified starting capacity and hasher. /// /// # Examples /// @@ -116,7 +116,7 @@ impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet { } /// Hash a given item to produce a usize. - /// Uses the provided or default HashBuilder. + /// Uses the provided or default `HashBuilder`. pub fn hash_usize(&self, item: &T) -> usize { self.inner.hash_usize(item) } @@ -252,7 +252,7 @@ impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet { self.inner.remove_if(key, |k, _| f(k)).map(|(k, _)| k) } - /// Creates an iterator over a DashMap yielding immutable references. + /// Creates an iterator over a `DashMap` yielding immutable references. /// /// # Examples /// diff --git a/src/try_result.rs b/src/try_result.rs index aa93d3b2..9391128f 100644 --- a/src/try_result.rs +++ b/src/try_result.rs @@ -1,4 +1,4 @@ -/// Represents the result of a non-blocking read from a [DashMap](crate::DashMap). +/// Represents the result of a non-blocking read from a [`DashMap`](crate::DashMap). #[derive(Debug)] pub enum TryResult { /// The value was present in the map, and the lock for the shard was successfully obtained.