Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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(); } ```
- Loading branch information