▲ 0 r/shortcuts
Don't Forget with Due my girlfriend is doing this to me
icloud.comu/IllustriousTime6197 — 1 day ago
[ Removed by Reddit on account of violating the content policy. ]
Hello,
what is a better practice? and why? Assume the key I want to insert is available in String type initially.
use std::collections::HashMap;
let mut map = HashMap::<String, u32>::new();
// a fct to add a key,value to my hashmap (I know it doesn't need to be implemented in this example but in my use case it does).
fn add_pair_v1(map: &mut HashMap::<String, u32>, s:String, u:u32){
map.insert(s,u);
}
//or
fn add_pair_v2(map:&mut HashMap::<String, u32>, s:&str, u:u32){
map.insert(s.to_string(),u);
}
Thank you !