Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5. println!("{:?}", {
  6. use std::collections::hash_map::{self, HashMap}; fn test() -> Result<(), ()> { let map: HashMap<String, String> = HashMap::new(); match map.entry("foo") { hash_map::Entry::Vacant(vacancy) => vacancy.insert("bar".to_owned()), hash_map::Entry::Occupied(_) => return Err(()) } Ok(()) }
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (/playground)
  13. error[E0308]: mismatched types
  14. --> src/main.rs:6:155
  15. |
  16. 6 | use std::collections::hash_map::{self, HashMap}; fn test() -> Result<(), ()> { let map: HashMap<String, String> = HashMap::new(); match map.entry("foo") { hash_map::Entry::Vacant(vacancy) => vacancy.insert("bar".to_owned()), hash_map::Entry::Occupied(_) => return Err(()) } Ok(()) }
  17. | ^^^^^
  18. | |
  19. | expected struct `std::string::String`, found reference
  20. | help: try using a conversion method: `"foo".to_string()`
  21. |
  22. = note: expected type `std::string::String`
  23. found type `&'static str`
  24.  
  25. error[E0308]: mismatched types
  26. --> src/main.rs:6:139
  27. |
  28. 6 | use std::collections::hash_map::{self, HashMap}; fn test() -> Result<(), ()> { let map: HashMap<String, String> = HashMap::new(); match map.entry("foo") { hash_map::Entry::Vacant(vacancy) => vacancy.insert("bar".to_owned()), hash_map::Entry::Occupied(_) => return Err(()) } Ok(()) }
  29. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found mutable reference
  30. |
  31. = note: expected type `()`
  32. found type `&mut std::string::String`
  33.  
  34. error: aborting due to 2 previous errors
  35.  
  36. For more information about this error, try `rustc --explain E0308`.
  37. error: Could not compile `playground`.
  38.  
  39. To learn more, run the command again with --verbose.
  40.  
  41. */
  42.  
  43. /* ~~~~=== stdout ===~~~~
  44.  
  45. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement