rust-lang / rust-lang/hashbrown

Question: Is the Clone bound on allocator in A: Allocator + Clone really necessary?

Open
#309 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3k
Forks
358
Avg merge
11h 57m
Merged PRs (30d)
2

Description

Hey :)

I am using the nightly allocator_api with a custom allocator. To guarantee safety in my setup, the allocator I have is not Clone.

This worked with collections in alloc, but hashbrown's allocator needs to be Clone. I tracked this requirement down to a single function: RawTableInner::prepare_resize, which has a couple of clients.

Hashbrown's codebase is way above my paygrade, but the general question is: is this just a limitation of the current implementation, or will it never be possible to remove the bound? Naturally, the allocator needs to be Clone, if the collection wants to implement Clone, but does it need to be Clone otherwise?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at RawTableInner::prepare_resize and trace the couple of clients identified in the issue, then compare their allocator requirements with the nightly allocator_api collections in alloc. Determine whether the Clone bound is required by those call paths or only by the current implementation; done means a documented conclusion or a focused change with tests showing non-Clone allocators work where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.