Skip to content

Commit

Permalink
Merge pull request #33 from KrishnaSannasi/remove-trait-bounds
Browse files Browse the repository at this point in the history
removed trait bounds on types
  • Loading branch information
xacrimon authored Jan 17, 2020
2 parents 27e5726 + 86ca1e3 commit b7d79cb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type GuardIterMut<'a, K, V, S> = (
/// map.insert("hello", "world");
/// assert_eq!(map.iter().count(), 1);
/// ```
pub struct Iter<'a, K: Eq + Hash, V, S: 'a + BuildHasher, M: Map<'a, K, V, S>> {
pub struct Iter<'a, K, V, S, M> {
map: &'a M,
shard_i: usize,
current: Option<GuardIter<'a, K, V, S>>,
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher, M: Map<'a, K, V, S>> Iterator
/// map.iter_mut().for_each(|mut r| *r += 1);
/// assert_eq!(*map.get("Johnny").unwrap(), 22);
/// ```
pub struct IterMut<'a, K: Eq + Hash, V, S: 'a + BuildHasher, M: Map<'a, K, V, S>> {
pub struct IterMut<'a, K, V, S, M> {
map: &'a M,
shard_i: usize,
current: Option<GuardIterMut<'a, K, V, S>>,
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ fn ncb(shard_amount: usize) -> usize {
/// DashMap tries to be very simple to use and to be a direct replacement for `RwLock<HashMap<K, V>>`.
/// To accomplish these all methods take `&self` instead 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.
pub struct DashMap<K, V, S = FxBuildHasher>
where
K: Eq + Hash,
S: BuildHasher + Clone,
{
pub struct DashMap<K, V, S = FxBuildHasher> {
ncb: usize,
shards: Box<[RwLock<HashMap<K, V, S>>]>,
hasher: S,
Expand Down
6 changes: 3 additions & 3 deletions src/mapref/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::hash::{BuildHasher, Hash};
use std::mem;
use std::ptr;

pub enum Entry<'a, K: Eq + Hash, V, S: BuildHasher = FxBuildHasher> {
pub enum Entry<'a, K, V, S = FxBuildHasher> {
Occupied(OccupiedEntry<'a, K, V, S>),
Vacant(VacantEntry<'a, K, V, S>),
}
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> Entry<'a, K, V, S> {
}
}

pub struct VacantEntry<'a, K: Eq + Hash, V, S> {
pub struct VacantEntry<'a, K, V, S> {
shard: RwLockWriteGuard<'a, HashMap<K, V, S>>,
key: K,
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> VacantEntry<'a, K, V, S> {
}
}

pub struct OccupiedEntry<'a, K: Eq + Hash, V, S: BuildHasher> {
pub struct OccupiedEntry<'a, K, V, S> {
shard: RwLockWriteGuard<'a, HashMap<K, V, S>>,
elem: (&'a K, &'a mut V),
key: Option<K>,
Expand Down
4 changes: 2 additions & 2 deletions src/mapref/multiple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;

// -- Shared

pub struct RefMulti<'a, K: Eq + Hash, V, S: BuildHasher = FxBuildHasher> {
pub struct RefMulti<'a, K, V, S = FxBuildHasher> {
_guard: Arc<RwLockReadGuard<'a, HashMap<K, V, S>>>,
k: &'a K,
v: &'a V,
Expand Down Expand Up @@ -63,7 +63,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> Deref for RefMulti<'a, K, V, S> {

// -- Unique

pub struct RefMutMulti<'a, K: Eq + Hash, V, S: BuildHasher = FxBuildHasher> {
pub struct RefMutMulti<'a, K, V, S = FxBuildHasher> {
_guard: Arc<RwLockWriteGuard<'a, HashMap<K, V, S>>>,
k: &'a K,
v: &'a mut V,
Expand Down
4 changes: 2 additions & 2 deletions src/mapref/one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::{Deref, DerefMut};

// -- Shared

pub struct Ref<'a, K: Eq + Hash, V, S: BuildHasher = FxBuildHasher> {
pub struct Ref<'a, K, V, S = FxBuildHasher> {
_guard: RwLockReadGuard<'a, HashMap<K, V, S>>,
k: &'a K,
v: &'a V,
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> Deref for Ref<'a, K, V, S> {

// -- Unique

pub struct RefMut<'a, K: Eq + Hash, V, S: BuildHasher = FxBuildHasher> {
pub struct RefMut<'a, K, V, S = FxBuildHasher> {
_guard: RwLockWriteGuard<'a, HashMap<K, V, S>>,
k: &'a K,
v: &'a mut V,
Expand Down
5 changes: 1 addition & 4 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use serde::Deserializer;
use std::fmt;
use std::hash::Hash;

pub struct DashMapVisitor<K, V>
where
K: Eq + Hash,
{
pub struct DashMapVisitor<K, V> {
marker: PhantomData<fn() -> DashMap<K, V>>,
}

Expand Down

0 comments on commit b7d79cb

Please sign in to comment.