Add a map::str_slice_map constructor to libstd.
This commit is contained in:
parent
958df4b003
commit
c1fad07758
@ -54,6 +54,7 @@ export
|
||||
|
||||
// Comparing strings
|
||||
eq,
|
||||
eq_slice,
|
||||
le,
|
||||
hash,
|
||||
|
||||
|
@ -389,6 +389,12 @@ fn hashmap<K: const, V: copy>(+hasher: hashfn<K>, +eqer: eqfn<K>)
|
||||
chained::mk(hasher, eqer)
|
||||
}
|
||||
|
||||
/// Construct a hashmap for string-slice keys
|
||||
fn str_slice_hash<V: copy>() -> hashmap<&str, V> {
|
||||
return hashmap(|s| hash::hash_str(*s) as uint,
|
||||
|a,b| str::eq_slice(*a, *b));
|
||||
}
|
||||
|
||||
/// Construct a hashmap for string keys
|
||||
fn str_hash<V: copy>() -> hashmap<~str, V> {
|
||||
return hashmap(str::hash, str::eq);
|
||||
|
Loading…
Reference in New Issue
Block a user