Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- 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(()) }
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0308]: mismatched types
- --> src/main.rs:6:155
- |
- 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(()) }
- | ^^^^^
- | |
- | expected struct `std::string::String`, found reference
- | help: try using a conversion method: `"foo".to_string()`
- |
- = note: expected type `std::string::String`
- found type `&'static str`
- error[E0308]: mismatched types
- --> src/main.rs:6:139
- |
- 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(()) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found mutable reference
- |
- = note: expected type `()`
- found type `&mut std::string::String`
- error: aborting due to 2 previous errors
- For more information about this error, try `rustc --explain E0308`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement