Created
May 13, 2016 00:49
-
-
Save izgzhen/e5b9d78c57152cc4db465e77b609c8d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Hash { | |
fn hash(&self) -> u64; | |
} | |
impl Hash for bool { | |
fn hash(&self) -> u64 { | |
if *self { 0 } else { 1 } | |
} | |
} | |
impl Hash for i64 { | |
fn hash(&self) -> u64 { | |
*self as u64 | |
} | |
} | |
fn print_hash<T: Hash>(t: &T) { | |
println!("The hash is {}", t.hash()) | |
} | |
struct HashMap<Key: Hash + Eq, Value> { | |
// Silly construct ... Just for demo purpose! | |
k: Key, | |
v: Value, | |
} | |
fn process(v: Vec<&Hash>) { | |
// whatever | |
} | |
fn main() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment