Skip to content

Commit 52bf3c8

Browse files
committed
feat: implement Default for ShardMap and ShardSet
closes #9
1 parent e05565d commit 52bf3c8

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/shard_map.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ impl<K, V, H> Clone for ShardMap<K, V, H> {
8383
}
8484
}
8585

86+
impl<K, V> Default for ShardMap<K, V, RandomState>
87+
where
88+
K: Eq + std::hash::Hash + 'static,
89+
V: 'static,
90+
{
91+
fn default() -> Self {
92+
Self::new()
93+
}
94+
}
95+
8696
#[inline(always)]
8797
fn calculate_shard_count() -> usize {
8898
(std::thread::available_parallelism().map_or(1, usize::from) * 4).next_power_of_two()

src/shard_set.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ pub struct ShardSet<T, S = RandomState> {
5454
inner: ShardMap<T, (), S>,
5555
}
5656

57+
impl<T: Eq + Hash + 'static> Default for ShardSet<T, RandomState> {
58+
fn default() -> Self {
59+
Self::new()
60+
}
61+
}
62+
5763
impl<T: Eq + Hash + 'static> ShardSet<T, RandomState> {
5864
pub fn new() -> Self {
5965
Self {

0 commit comments

Comments
 (0)