Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- 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())))
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (file:///playground)
- error[E0599]: no method named `finish` found for type `std::collections::hash_map::DefaultHasher` in the current scope
- --> src/main.rs:6:190
- |
- 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())))
- | ^^^^^^
- |
- = help: items from traits can only be used if the trait is in scope
- help: the following trait is implemented but not in scope, perhaps add a `use` for it:
- |
- 4 | use std::hash::Hasher;
- |
- error: aborting due to previous error
- For more information about this error, try `rustc --explain E0599`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Add Comment
Please, Sign In to add comment