diff --git a/src/lib.rs b/src/lib.rs index a6f73f2..0d3cf7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,9 +23,7 @@ //! Notice that there is a trade-off here. Creating and dropping a `Guard` is not free, since it //! also needs to interact with said bookkeeping. But if you keep one around for a long time, you //! may accumulate much garbage which will take up valuable free memory on your system. Use your -//! best judgement in deciding whether or not to re-use a `Guard`. This is also the reason why the -//! map requires that `K: 'static` and `V: 'static`. If we did not, then your keys and values may -//! get dropped far later, potentially after those lifetimes have passed, which would not be sound. +//! best judgement in deciding whether or not to re-use a `Guard`. //! //! # Consistency //! diff --git a/src/map.rs b/src/map.rs index 0a05b9a..69c1484 100644 --- a/src/map.rs +++ b/src/map.rs @@ -214,7 +214,7 @@ where // === // the following methods only see Ks and Vs if there have been inserts. -// modifications to the map are all guarded by thread-safety bounds (Send + Sync + 'static). +// modifications to the map are all guarded by thread-safety bounds (Send + Sync ). // but _these_ methods do not need to be, since they will never introduce keys or values, only give // out ones that have already been inserted (which implies they must be thread-safe). // === @@ -1602,8 +1602,8 @@ where impl HashMap where - K: 'static + Sync + Send + Clone + Hash + Ord, - V: 'static + Sync + Send, + K: Sync + Send + Clone + Hash + Ord, + V: Sync + Send, S: BuildHasher, { /// Inserts a key-value pair into the map. @@ -3007,8 +3007,8 @@ impl Drop for HashMap { impl Extend<(K, V)> for &HashMap where - K: 'static + Sync + Send + Clone + Hash + Ord, - V: 'static + Sync + Send, + K: Sync + Send + Clone + Hash + Ord, + V: Sync + Send, S: BuildHasher, { fn extend>(&mut self, iter: T) { @@ -3032,8 +3032,8 @@ where impl<'a, K, V, S> Extend<(&'a K, &'a V)> for &HashMap where - K: 'static + Sync + Send + Copy + Hash + Ord, - V: 'static + Sync + Send + Copy, + K: Sync + Send + Copy + Hash + Ord, + V: Sync + Send + Copy, S: BuildHasher, { fn extend>(&mut self, iter: T) { @@ -3043,8 +3043,8 @@ where impl FromIterator<(K, V)> for HashMap where - K: 'static + Sync + Send + Clone + Hash + Ord, - V: 'static + Sync + Send, + K: Sync + Send + Clone + Hash + Ord, + V: Sync + Send, S: BuildHasher + Default, { fn from_iter>(iter: T) -> Self { @@ -3069,8 +3069,8 @@ where impl<'a, K, V, S> FromIterator<(&'a K, &'a V)> for HashMap where - K: 'static + Sync + Send + Copy + Hash + Ord, - V: 'static + Sync + Send + Copy, + K: Sync + Send + Copy + Hash + Ord, + V: Sync + Send + Copy, S: BuildHasher + Default, { fn from_iter>(iter: T) -> Self { @@ -3080,8 +3080,8 @@ where impl<'a, K, V, S> FromIterator<&'a (K, V)> for HashMap where - K: 'static + Sync + Send + Copy + Hash + Ord, - V: 'static + Sync + Send + Copy, + K: Sync + Send + Copy + Hash + Ord, + V: Sync + Send + Copy, S: BuildHasher + Default, { fn from_iter>(iter: T) -> Self { @@ -3091,8 +3091,8 @@ where impl Clone for HashMap where - K: 'static + Sync + Send + Clone + Hash + Ord, - V: 'static + Sync + Send + Clone, + K: Sync + Send + Clone + Hash + Ord, + V: Sync + Send + Clone, S: BuildHasher + Clone, { fn clone(&self) -> HashMap { diff --git a/src/map_ref.rs b/src/map_ref.rs index 1bffede..0b339ef 100644 --- a/src/map_ref.rs +++ b/src/map_ref.rs @@ -149,8 +149,8 @@ where impl HashMapRef<'_, K, V, S> where - K: 'static + Sync + Send + Clone + Hash + Ord, - V: 'static + Sync + Send, + K: Sync + Send + Clone + Hash + Ord, + V: Sync + Send, S: BuildHasher, { /// Inserts a key-value pair into the map. diff --git a/src/rayon_impls.rs b/src/rayon_impls.rs index 43b23a1..caee707 100644 --- a/src/rayon_impls.rs +++ b/src/rayon_impls.rs @@ -4,8 +4,8 @@ use std::hash::{BuildHasher, Hash}; impl FromParallelIterator<(K, V)> for HashMap where - K: Clone + Hash + Ord + Send + Sync + 'static, - V: Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, + V: Send + Sync, S: BuildHasher + Default + Sync, { fn from_par_iter(par_iter: I) -> Self @@ -20,8 +20,8 @@ where impl ParallelExtend<(K, V)> for HashMap where - K: Clone + Hash + Ord + Send + Sync + 'static, - V: Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, + V: Send + Sync, S: BuildHasher + Sync, { fn par_extend(&mut self, par_iter: I) @@ -34,8 +34,8 @@ where impl ParallelExtend<(K, V)> for &HashMap where - K: Clone + Hash + Ord + Send + Sync + 'static, - V: Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, + V: Send + Sync, S: BuildHasher + Sync, { fn par_extend(&mut self, par_iter: I) @@ -53,8 +53,8 @@ where impl<'map, K, V, S> ParallelExtend<(K, V)> for HashMapRef<'map, K, V, S> where - K: Clone + Hash + Ord + Send + Sync + 'static, - V: Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, + V: Send + Sync, S: BuildHasher + Sync, { fn par_extend(&mut self, par_iter: I) @@ -67,7 +67,7 @@ where impl FromParallelIterator for HashSet where - K: Clone + Hash + Ord + Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, S: BuildHasher + Default + Sync, { fn from_par_iter(par_iter: I) -> Self @@ -82,7 +82,7 @@ where impl ParallelExtend for HashSet where - K: Clone + Hash + Ord + Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, S: BuildHasher + Sync, { fn par_extend(&mut self, par_iter: I) @@ -95,7 +95,7 @@ where impl ParallelExtend for &HashSet where - K: Clone + Hash + Ord + Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, S: BuildHasher + Sync, { fn par_extend(&mut self, par_iter: I) @@ -109,7 +109,7 @@ where impl<'set, K, S> ParallelExtend for HashSetRef<'set, K, S> where - K: Clone + Hash + Ord + Send + Sync + 'static, + K: Clone + Hash + Ord + Send + Sync, S: BuildHasher + Sync, { fn par_extend(&mut self, par_iter: I) diff --git a/src/serde_impls.rs b/src/serde_impls.rs index 9154bcc..aa08721 100644 --- a/src/serde_impls.rs +++ b/src/serde_impls.rs @@ -41,8 +41,8 @@ where impl<'de, K, V, S> Deserialize<'de> for HashMap where - K: 'static + Deserialize<'de> + Send + Sync + Hash + Clone + Ord, - V: 'static + Deserialize<'de> + Send + Sync + Ord, + K: Deserialize<'de> + Send + Sync + Hash + Clone + Ord, + V: Deserialize<'de> + Send + Sync + Ord, S: Default + BuildHasher, { fn deserialize(deserializer: D) -> Result @@ -65,8 +65,8 @@ impl HashMapVisitor { impl<'de, K, V, S> Visitor<'de> for HashMapVisitor where - K: 'static + Deserialize<'de> + Send + Sync + Hash + Clone + Ord, - V: 'static + Deserialize<'de> + Send + Sync + Ord, + K: Deserialize<'de> + Send + Sync + Hash + Clone + Ord, + V: Deserialize<'de> + Send + Sync + Ord, S: Default + BuildHasher, { type Value = HashMap; @@ -124,7 +124,7 @@ where impl<'de, T, S> Deserialize<'de> for HashSet where - T: 'static + Deserialize<'de> + Send + Sync + Hash + Clone + Ord, + T: Deserialize<'de> + Send + Sync + Hash + Clone + Ord, S: Default + BuildHasher, { fn deserialize(deserializer: D) -> Result @@ -151,7 +151,7 @@ impl HashSetVisitor { impl<'de, T, S> Visitor<'de> for HashSetVisitor where - T: 'static + Deserialize<'de> + Send + Sync + Hash + Clone + Ord, + T: Deserialize<'de> + Send + Sync + Hash + Clone + Ord, S: Default + BuildHasher, { type Value = HashSet; diff --git a/src/set.rs b/src/set.rs index 89eb2a2..69a4317 100644 --- a/src/set.rs +++ b/src/set.rs @@ -384,7 +384,7 @@ where impl HashSet where - T: 'static + Sync + Send + Clone + Hash + Ord, + T: Sync + Send + Clone + Hash + Ord, S: BuildHasher, { /// Adds a value to the set. @@ -556,7 +556,7 @@ where impl Extend for &HashSet where - T: 'static + Sync + Send + Clone + Hash + Ord, + T: Sync + Send + Clone + Hash + Ord, S: BuildHasher, { fn extend>(&mut self, iter: I) { @@ -566,7 +566,7 @@ where impl<'a, T, S> Extend<&'a T> for &HashSet where - T: 'static + Sync + Send + Copy + Hash + Ord, + T: Sync + Send + Copy + Hash + Ord, S: BuildHasher, { fn extend>(&mut self, iter: I) { @@ -576,7 +576,7 @@ where impl FromIterator for HashSet where - T: 'static + Sync + Send + Clone + Hash + Ord, + T: Sync + Send + Clone + Hash + Ord, S: BuildHasher + Default, { fn from_iter>(iter: I) -> Self { @@ -588,7 +588,7 @@ where impl<'a, T, S> FromIterator<&'a T> for HashSet where - T: 'static + Sync + Send + Copy + Hash + Ord, + T: Sync + Send + Copy + Hash + Ord, S: BuildHasher + Default, { fn from_iter>(iter: I) -> Self { @@ -600,7 +600,7 @@ where impl Clone for HashSet where - T: 'static + Sync + Send + Clone + Hash + Ord, + T: Sync + Send + Clone + Hash + Ord, S: BuildHasher + Clone, { fn clone(&self) -> HashSet { diff --git a/src/set_ref.rs b/src/set_ref.rs index ba145f6..ff2d2a7 100644 --- a/src/set_ref.rs +++ b/src/set_ref.rs @@ -112,7 +112,7 @@ where impl HashSetRef<'_, T, S> where - T: 'static + Sync + Send + Clone + Hash + Ord, + T: Sync + Send + Clone + Hash + Ord, S: BuildHasher, { /// Adds a value to the set. diff --git a/tests/jdk/concurrent_associate.rs b/tests/jdk/concurrent_associate.rs index d7458da..d3c3231 100644 --- a/tests/jdk/concurrent_associate.rs +++ b/tests/jdk/concurrent_associate.rs @@ -32,7 +32,7 @@ fn test_concurrent_insert<'g>() { fn test(associator: F) where - F: Fn(Arc>, KeyVal) + Send + Copy + 'static, + F: Fn(Arc>, KeyVal) + Send + Copy, { for _ in 0..ITERATIONS { test_once(associator); @@ -41,7 +41,7 @@ where fn test_once(associator: F) where - F: Fn(Arc>, KeyVal) + Send + Copy + 'static, + F: Fn(Arc>, KeyVal) + Send + Copy, { let map = Arc::new(HashMap::new()); let mut threads = Vec::new(); diff --git a/tests/jdk/map_check.rs b/tests/jdk/map_check.rs index aac648a..401fe9d 100644 --- a/tests/jdk/map_check.rs +++ b/tests/jdk/map_check.rs @@ -35,7 +35,7 @@ where fn t2(map: &HashMap, keys: &[K], expect: usize) where - K: 'static + Sync + Send + Copy + Hash + Ord + std::fmt::Display, + K: Sync + Send + Copy + Hash + Ord + std::fmt::Display, { let mut sum = 0; let guard = map.guard(); @@ -49,7 +49,7 @@ where fn t3(map: &HashMap, keys: &[K], expect: usize) where - K: 'static + Sync + Send + Copy + Hash + Ord, + K: Sync + Send + Copy + Hash + Ord, { let mut sum = 0; let guard = map.guard(); @@ -77,7 +77,7 @@ where fn t5(map: &HashMap, keys: &[K], expect: usize) where - K: 'static + Sync + Send + Copy + Hash + Ord, + K: Sync + Send + Copy + Hash + Ord, { let mut sum = 0; let guard = map.guard();