Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HashMap.mangle no longer exists #13195

Closed
huonw opened this issue Mar 29, 2014 · 5 comments
Closed

HashMap.mangle no longer exists #13195

huonw opened this issue Mar 29, 2014 · 5 comments

Comments

@huonw
Copy link
Member

huonw commented Mar 29, 2014

There's now no way to be able to conditionally execute expensive functionality when inserting both when the key is not found, and when the key is found, without hashing twice.

See the 0.9 docs for signature.

cc @cgaebel, was this removed on purpose?

@huonw huonw added the A-libs label Mar 29, 2014
@huonw
Copy link
Member Author

huonw commented Mar 29, 2014

(mangle was also useful as a building block for essentially all the other insertion methods, see the 0.9/pre-robin-hood-hashmap source for how it was used.)

@cgaebel
Copy link
Contributor

cgaebel commented Mar 29, 2014

This was not removed on purpose. However, its benefits are only that you save a rehashing, as with robin hood hashing you must know whether you are inserting or looking up when you probe the table, to know whether or not you need to steal buckets.

@cgaebel
Copy link
Contributor

cgaebel commented Mar 29, 2014

I feel like there's room for a more usable and powerful abstraction here. Something like:

pub struct HashWithKey<K, 'a> {
  priv hash: SafeHash;
  priv key: &'a K;
}

impl<K, 'a> HashWithKey<K, 'a> {
  pub fn key(&self) -> &'a K;
  fn hash(&self) -> &'a SafeHash;
}

pub fn hash<'a>(&self, k: &'a K) -> HashWithKey<K, 'a>

And expose all my methods that take a prehashed key.

@bluss
Copy link
Member

bluss commented May 26, 2014

Fixed by #14196

@alexcrichton
Copy link
Member

Hurray!

flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 8, 2024
…83, r=Manishearth

Fix false positive for `missing_backticks` in footnote references

Fixes rust-lang#13183.

changelog: Fix false positive for `missing_backticks` in footnote references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants