Skip to content

Instantly share code, notes, and snippets.

@jroesch
Last active August 29, 2015 14:24
Show Gist options
  • Save jroesch/9d1f9c1e10d25546c2c9 to your computer and use it in GitHub Desktop.
Save jroesch/9d1f9c1e10d25546c2c9 to your computer and use it in GitHub Desktop.
use std::marker::PhantomData;
trait TypeEq<A> {}
impl<A> TypeEq<A> for A {}
struct DeterministicHasher;
struct RandomHasher;
struct MyHashMap<K, V, H=DeterministicHasher> {
data: PhantomData<(K, V, H)>
}
impl<K, V, H> MyHashMap<K, V, H> {
fn new() -> MyHashMap<K, V, H> {
MyHashMap { data: PhantomData }
}
}
mod mystd {
use super::{MyHashMap, RandomHasher};
pub type HashMap<K, V, H=RandomHasher> = MyHashMap<K, V, H>;
}
fn try_me<H>(hash_map: mystd::HashMap<i32, i32, H>) {}
fn main() {
let hash_map = mystd::HashMap::new();
try_me(hash_map);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment