Skip to content

Commit c1fad07

Browse files
committed
Add a map::str_slice_map constructor to libstd.
1 parent 958df4b commit c1fad07

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/libcore/str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export
5454

5555
// Comparing strings
5656
eq,
57+
eq_slice,
5758
le,
5859
hash,
5960

src/libstd/map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ fn hashmap<K: const, V: copy>(+hasher: hashfn<K>, +eqer: eqfn<K>)
389389
chained::mk(hasher, eqer)
390390
}
391391

392+
/// Construct a hashmap for string-slice keys
393+
fn str_slice_hash<V: copy>() -> hashmap<&str, V> {
394+
return hashmap(|s| hash::hash_str(*s) as uint,
395+
|a,b| str::eq_slice(*a, *b));
396+
}
397+
392398
/// Construct a hashmap for string keys
393399
fn str_hash<V: copy>() -> hashmap<~str, V> {
394400
return hashmap(str::hash, str::eq);

0 commit comments

Comments
 (0)