id0om 유형의 ~str
키가있는 HashMap을 사용하는 방법을 알아내는 데 문제가 있습니다. 예를 들어, this 버그 리포트를 바탕으로문자열 키 HashMap 녹이?
let mut map: hashmap::HashMap<~str, int> = hashmap::HashMap::new();
// Inserting is fine, I just have to copy the string.
map.insert("hello".to_str(), 1);
// If I look something up, do I really need to copy the string?
// This works:
map.contains_key(&"hello".to_str());
// This doesn't: as expected, I get
// error: mismatched types: expected `&~str` but found `&'static str` (expected &-ptr but found &'static str)
map.contains_key("hello");
, 나는
map.contains_key_equiv("hello");
을 시도했지만
error: mismatched types: expected `&<V367>` but found `&'static str` (expected &-ptr but found &'static str)
난 정말이 마지막 메시지를 이해하지 못하고 있어요; 누구든지 제안이 있습니까?