Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub trait Hash {
- fn hash(&self) -> usize;
- }
- impl Hash for usize {
- fn hash(&self) -> usize {
- *self % 10
- }
- }
- impl Hash for String {
- fn hash(&self) -> usize {
- self.len() % 24
- }
- }
- fn foo(x: impl Hash) {
- println!("hash is {}", x.hash());
- }
- fn main() {
- foo(32usize);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement