From 86ca1e3e61bfab144cfd373c4b68c34f83eb8e91 Mon Sep 17 00:00:00 2001 From: Ozaren Date: Thu, 16 Jan 2020 15:34:26 -0700 Subject: [PATCH] removed trait bounds on types --- src/iter.rs | 4 ++-- src/lib.rs | 6 +----- src/mapref/entry.rs | 6 +++--- src/mapref/multiple.rs | 4 ++-- src/mapref/one.rs | 4 ++-- src/serde.rs | 5 +---- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/iter.rs b/src/iter.rs index 6d331ed6..c76b4d16 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -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>, @@ -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>, diff --git a/src/lib.rs b/src/lib.rs index 6ecdabca..b418e812 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,11 +50,7 @@ fn ncb(shard_amount: usize) -> usize { /// DashMap tries to be very simple to use and to be a direct replacement for `RwLock>`. /// To accomplish these all methods take `&self` instead 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. -pub struct DashMap -where - K: Eq + Hash, - S: BuildHasher + Clone, -{ +pub struct DashMap { ncb: usize, shards: Box<[RwLock>]>, } diff --git a/src/mapref/entry.rs b/src/mapref/entry.rs index b8eda889..f72239b3 100644 --- a/src/mapref/entry.rs +++ b/src/mapref/entry.rs @@ -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>), } @@ -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>, key: K, } @@ -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>, elem: (&'a K, &'a mut V), key: Option, diff --git a/src/mapref/multiple.rs b/src/mapref/multiple.rs index b6b1175b..d7084cb8 100644 --- a/src/mapref/multiple.rs +++ b/src/mapref/multiple.rs @@ -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>>, k: &'a K, v: &'a V, @@ -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>>, k: &'a K, v: &'a mut V, diff --git a/src/mapref/one.rs b/src/mapref/one.rs index e88b3450..29822c72 100644 --- a/src/mapref/one.rs +++ b/src/mapref/one.rs @@ -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: &'a K, v: &'a V, @@ -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: &'a K, v: &'a mut V, diff --git a/src/serde.rs b/src/serde.rs index 7b96eaab..9fce4978 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -6,10 +6,7 @@ use serde::Deserializer; use std::fmt; use std::hash::Hash; -pub struct DashMapVisitor -where - K: Eq + Hash, -{ +pub struct DashMapVisitor { marker: PhantomData DashMap>, }