Closed
Description
type StringMap<T> = HashMap<~str, T>; //Fairly common
fn foo(map:&mut StringMap<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.
Related to #3284 - probably.
Metadata
Metadata
Assignees
Labels
No labels