You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeStringMap<T> = HashMap<~str,T>;//Fairly commonfnfoo(map:&mutStringMap<uint>){
map.insert("Test".to_str(),1);// This works fine, copying the string isn't unexpected
map.find("Test");//Nope. its a &'static str, not a ~str, so the types don't match, the only work around is copying the string}
Copying the string in order to do a lookup is plain ridiculous. It adds significant overhead where it isn't needed. Now, I'm not sure how to fix it, but this is a common enough case that it should be dealt with.
You can use the find_equiv method to do a lookup with &str in a HashMap with ~str keys. This same issue exists in C++ with the standard containers, but there's no workaround like find_equiv.
Copying the string in order to do a lookup is plain ridiculous. It adds significant overhead where it isn't needed. Now, I'm not sure how to fix it, but this is a common enough case that it should be dealt with.
Related to #3284 - probably.
The text was updated successfully, but these errors were encountered: