Skip to content

Commit d2cf016

Browse files
authored
Make with_hasher const (#73)
1 parent 1fb35ce commit d2cf016

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/double_priority_queue/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ where
162162
H: BuildHasher,
163163
{
164164
/// Creates an empty `DoublePriorityQueue` with the specified hasher
165-
pub fn with_hasher(hash_builder: H) -> Self {
166-
Self::with_capacity_and_hasher(0, hash_builder)
165+
pub const fn with_hasher(hash_builder: H) -> Self {
166+
Self {
167+
store: Store::with_hasher(hash_builder),
168+
}
167169
}
168170

169171
/// Creates an empty `DoublePriorityQueue` with the specified capacity and hasher

src/priority_queue/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ where
153153
H: BuildHasher,
154154
{
155155
/// Creates an empty `PriorityQueue` with the specified hasher
156-
pub fn with_hasher(hash_builder: H) -> Self {
157-
Self::with_capacity_and_hasher(0, hash_builder)
156+
pub const fn with_hasher(hash_builder: H) -> Self {
157+
Self {
158+
store: Store::with_hasher(hash_builder),
159+
}
158160
}
159161

160162
/// Creates an empty `PriorityQueue` with the specified capacity and hasher

src/store.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,13 @@ where
134134
H: BuildHasher,
135135
{
136136
/// Creates an empty `Store` with the specified hasher
137-
pub fn with_hasher(hash_builder: H) -> Self {
138-
Self::with_capacity_and_hasher(0, hash_builder)
137+
pub const fn with_hasher(hash_builder: H) -> Self {
138+
Self {
139+
map: IndexMap::with_hasher(hash_builder),
140+
heap: Vec::new(),
141+
qp: Vec::new(),
142+
size: 0,
143+
}
139144
}
140145

141146
/// Creates an empty `Store` with the specified capacity and hasher

0 commit comments

Comments
 (0)