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

Consider adding a typealias for slightly easier use #8

Open
shepmaster opened this issue Sep 13, 2016 · 1 comment
Open

Consider adding a typealias for slightly easier use #8

shepmaster opened this issue Sep 13, 2016 · 1 comment

Comments

@shepmaster
Copy link
Owner

shepmaster commented Sep 13, 2016

From Reddit:

pub type XxHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder>;

The saddest thing is the inability to use new or with_capacity.

@shepmaster
Copy link
Owner Author

Or maybe... we can?

use std::marker::PhantomData;

struct HashLike<K, V, H>(PhantomData<K>, PhantomData<V>, H);
struct DefaultHasher;

impl<K, V> HashLike<K, V, DefaultHasher> {
    fn new() -> HashLike<K, V, DefaultHasher> {
        HashLike(PhantomData, PhantomData, DefaultHasher)
    }
}

// But what about another crate...
struct AnotherHasher;

impl<K, V> HashLike<K, V, AnotherHasher> {
    fn new() -> HashLike<K, V, AnotherHasher> {
        HashLike(PhantomData, PhantomData, AnotherHasher)
    }
}

fn main() {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant