diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 8584d4f1524a..5c02571ef978 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -54,6 +54,7 @@ export // Comparing strings eq, + eq_slice, le, hash, diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 071ef5952e00..699cf7a66e95 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -389,6 +389,12 @@ fn hashmap(+hasher: hashfn, +eqer: eqfn) chained::mk(hasher, eqer) } +/// Construct a hashmap for string-slice keys +fn str_slice_hash() -> 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() -> hashmap<~str, V> { return hashmap(str::hash, str::eq);