Commit 5a6c1df
committed
Auto merge of #252 - optimalstrategy:add-alloc-to-clone-impls, r=Amanieu
Add an allocator type parameter to HashMap's and HashSet's Clone impls
HashMap's and HashSet's Clone implementations are missing the type parameter for a custom allocator, which makes them a lot less usable with custom allocators. Curiously, the parameter is present on RawTable's Clone implementation, so I figured that this must be an accident. This PR adds the parameter to HashMap and HashSet's Clone impls.
Here's a minimal reproducible example:
```rust
#![feature(allocator_api)]
use std::{
alloc::{AllocError, Allocator, Global, Layout},
ptr::NonNull,
};
use hashbrown::HashMap;
#[derive(Debug, Clone, Copy)]
pub struct DummyAllocator;
unsafe impl Allocator for DummyAllocator {
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
Global.allocate(layout)
}
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
Global.deallocate(ptr, layout)
}
}
fn main() {
let map = HashMap::new_in(DummyAllocator);
// Error: no method named `clone` found for struct `hashbrown::HashMap<&str, &str, ahash::random_state::RandomState, DummyAllocator>` in the current scope
let map2 = map.clone();
}
```2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
0 commit comments