Skip to content
Open

Lints #282

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -101,7 +101,7 @@ type GuardIterMut<'a, K, V, S> = (
hash_map::IterMut<'a, K, SharedValue<V>>,
);

/// Iterator over a DashMap yielding immutable references.
/// Iterator over a `DashMap` yielding immutable references.
///
/// # Examples
///
Expand Down Expand Up @@ -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
///
Expand Down
50 changes: 25 additions & 25 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashMap<K, V, S>>`.
/// `DashMap` tries to be very simple to use and to be a direct replacement for `RwLock<HashMap<K, V, S>>`.
/// To accomplish this, all methods take `&self` instead of modifying methods taking `&mut self`.
/// This allows you to put a DashMap in an `Arc<T>` and share it between threads while being able to modify it.
/// This allows you to put a `DashMap` in an `Arc<T>` 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.
Expand Down Expand Up @@ -120,7 +120,7 @@ where
}

impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V, RandomState> {
/// Creates a new DashMap with a capacity of 0.
/// Creates a new `DashMap` with a capacity of 0.
///
/// # Examples
///
Expand All @@ -134,7 +134,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V, RandomState> {
DashMap::with_hasher(RandomState::default())
}

/// Creates a new DashMap with a specified starting capacity.
/// Creates a new `DashMap` with a specified starting capacity.
///
/// # Examples
///
Expand All @@ -149,10 +149,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V, RandomState> {
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
///
Expand All @@ -167,10 +167,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V, RandomState> {
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
///
Expand All @@ -196,7 +196,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
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
///
Expand All @@ -212,7 +212,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
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
///
Expand All @@ -229,10 +229,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
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
///
Expand All @@ -249,10 +249,10 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
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
///
Expand Down Expand Up @@ -293,7 +293,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
}

/// Hash a given item to produce a usize.
/// Uses the provided or default HashBuilder.
/// Uses the provided or default `HashBuilder`.
pub fn hash_usize<T: Hash>(&self, item: &T) -> usize {
let mut hasher = self.hasher.build_hasher();

Expand Down Expand Up @@ -517,7 +517,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
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.
///
Expand All @@ -534,7 +534,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
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.
///
Expand Down Expand Up @@ -596,7 +596,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
}

/// 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
///
Expand All @@ -623,7 +623,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
}

/// 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
///
Expand Down
4 changes: 2 additions & 2 deletions src/mapref/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/mapref/one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
Expand Down Expand Up @@ -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),
};
Expand Down
14 changes: 7 additions & 7 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@ where
}

impl<'a, K: 'a + Eq + Hash> DashSet<K, RandomState> {
/// Creates a new DashSet with a capacity of 0.
/// Creates a new `DashSet` with a capacity of 0.
///
/// # Examples
///
Expand All @@ -63,7 +63,7 @@ impl<'a, K: 'a + Eq + Hash> DashSet<K, RandomState> {
Self::with_hasher(RandomState::default())
}

/// Creates a new DashMap with a specified starting capacity.
/// Creates a new `DashMap` with a specified starting capacity.
///
/// # Examples
///
Expand All @@ -80,7 +80,7 @@ impl<'a, K: 'a + Eq + Hash> DashSet<K, RandomState> {
}

impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet<K, S> {
/// 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
///
Expand All @@ -96,7 +96,7 @@ impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet<K, S> {
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
///
Expand All @@ -116,7 +116,7 @@ impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet<K, S> {
}

/// Hash a given item to produce a usize.
/// Uses the provided or default HashBuilder.
/// Uses the provided or default `HashBuilder`.
pub fn hash_usize<T: Hash>(&self, item: &T) -> usize {
self.inner.hash_usize(item)
}
Expand Down Expand Up @@ -252,7 +252,7 @@ impl<'a, K: 'a + Eq + Hash, S: BuildHasher + Clone> DashSet<K, S> {
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
///
Expand Down
2 changes: 1 addition & 1 deletion src/try_result.rs
Original file line number Diff line number Diff line change
@@ -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<R> {
/// The value was present in the map, and the lock for the shard was successfully obtained.
Expand Down