Skip to content

Instantly share code, notes, and snippets.

@Thiez
Forked from anonymous/playground.rs
Last active July 7, 2016 09:00
Show Gist options
  • Save Thiez/3ea39cb2401a96926c2fb8f9ecf6230a to your computer and use it in GitHub Desktop.
Save Thiez/3ea39cb2401a96926c2fb8f9ecf6230a to your computer and use it in GitHub Desktop.
Shared via Rust Playground
use std::collections::HashMap;
fn main() {
let port = "1025";
// Works if I reverse these two lines
let mut data = HashMap::new();
let port = port.to_string();
data.insert("port", &port);
println!("{:?}", data);
drop(data); // Ensure `data` is destroyed *before* `port`.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment