From c1fad0775844a9413484fd2eaa10adcfdfbc2883 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 14 Aug 2012 16:45:00 -0700 Subject: Add a map::str_slice_map constructor to libstd. --- src/libstd/map.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 071ef5952e0..699cf7a66e9 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); -- cgit 1.4.1-3-g733a5