Guest User

Untitled

a guest
Oct 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5. println!("{:?}", {
  6. use ::std::collections::hash_map::DefaultHasher; use ::std::hash::Hash; fn hash<T: Hash>(object: T) -> u64 { let mut hasher = DefaultHasher::new(); object.hash(&mut hasher); hasher.finish() } #[derive(Debug, Hash)] enum Foo { String(String), Int(i32) } let value = "egg"; (hash(value), hash(Foo::String(value.to_owned())))
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (file:///playground)
  13. error[E0599]: no method named `finish` found for type `std::collections::hash_map::DefaultHasher` in the current scope
  14. --> src/main.rs:6:190
  15. |
  16. 6 | use ::std::collections::hash_map::DefaultHasher; use ::std::hash::Hash; fn hash<T: Hash>(object: T) -> u64 { let mut hasher = DefaultHasher::new(); object.hash(&mut hasher); hasher.finish() } #[derive(Debug, Hash)] enum Foo { String(String), Int(i32) } let value = "egg"; (hash(value), hash(Foo::String(value.to_owned())))
  17. | ^^^^^^
  18. |
  19. = help: items from traits can only be used if the trait is in scope
  20. help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  21. |
  22. 4 | use std::hash::Hasher;
  23. |
  24.  
  25. error: aborting due to previous error
  26.  
  27. For more information about this error, try `rustc --explain E0599`.
  28. error: Could not compile `playground`.
  29.  
  30. To learn more, run the command again with --verbose.
  31.  
  32. */
  33.  
  34. /* ~~~~=== stdout ===~~~~
  35.  
  36. */
Add Comment
Please, Sign In to add comment