diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-03-14 12:07:23 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-03-14 18:19:08 -0700 |
| commit | 3864d6d845f6bf9493698606bba2220daede4738 (patch) | |
| tree | 206d35d98526bec1424c87f4c77af141e99bec4b /src/libstd | |
| parent | 383a80199351c6b9f9f4834242231c8586fb2ab6 (diff) | |
| download | rust-3864d6d845f6bf9493698606bba2220daede4738.tar.gz rust-3864d6d845f6bf9493698606bba2220daede4738.zip | |
std: Rename the hashmap constructors to conform to new standards
Instead of using the new_ prefix just name them after their type
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ebml.rs | 6 | ||||
| -rw-r--r-- | src/libstd/json.rs | 4 | ||||
| -rw-r--r-- | src/libstd/map.rs | 42 | ||||
| -rw-r--r-- | src/libstd/uv.rs | 12 |
4 files changed, 31 insertions, 33 deletions
diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 364eb16408c..40c44da8b45 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -7,8 +7,6 @@ import core::option; import option::{some, none}; export doc; - -export new_doc; export doc_at; export maybe_get_doc; export get_doc; @@ -64,7 +62,7 @@ fn vuint_at(data: [u8], start: uint) -> {val: uint, next: uint} { } else { #error("vint too big"); fail; } } -fn new_doc(data: @[u8]) -> doc { +fn doc(data: @[u8]) -> doc { ret {data: data, start: 0u, end: vec::len::<u8>(*data)}; } @@ -575,7 +573,7 @@ fn test_option_int() { let mbuf = io::mem_buffer(); let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf)); serialize_0(ebml_w, v); - let ebml_doc = ebml::new_doc(@io::mem_buffer_buf(mbuf)); + let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf)); let deser = ebml_deserializer(ebml_doc); let v1 = deserialize_0(deser); #debug["v1 == %?", v1]; diff --git a/src/libstd/json.rs b/src/libstd/json.rs index b5f526da2ed..216c881ab40 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -407,7 +407,7 @@ impl parser for parser { self.bump(); self.parse_whitespace(); - let values = map::new_str_hash(); + let values = map::str_hash(); if self.ch == '}' { self.bump(); @@ -501,7 +501,7 @@ fn eq(value0: json, value1: json) -> bool { #[cfg(test)] mod tests { fn mk_dict(items: [(str, json)]) -> json { - let d = map::new_str_hash(); + let d = map::str_hash(); vec::iter(items) { |item| let (key, value) = item; diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 53eb04fe070..f5302082b8d 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -1,8 +1,8 @@ #[doc = "A map type"]; import chained::hashmap; -export hashmap, hashfn, eqfn, set, map, chained, new_hashmap, new_str_hash; -export new_bytes_hash, new_int_hash, new_uint_hash, set_add; +export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash; +export bytes_hash, int_hash, uint_hash, set_add; #[doc = " A function that returns a hash of a value @@ -289,7 +289,7 @@ mod chained { } /* -Function: new_hashmap +Function: hashmap Construct a hashmap. @@ -298,33 +298,33 @@ Parameters: hasher - The hash function for key type K eqer - The equality function for key type K */ -fn new_hashmap<K: copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) +fn hashmap<K: copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) -> hashmap<K, V> { chained::mk(hasher, eqer) } #[doc = "Construct a hashmap for string keys"] -fn new_str_hash<V: copy>() -> hashmap<str, V> { - ret new_hashmap(str::hash, str::eq); +fn str_hash<V: copy>() -> hashmap<str, V> { + ret hashmap(str::hash, str::eq); } #[doc = "Construct a hashmap for byte string keys"] -fn new_bytes_hash<V: copy>() -> hashmap<[u8], V> { - ret new_hashmap(vec::u8::hash, vec::u8::eq); +fn bytes_hash<V: copy>() -> hashmap<[u8], V> { + ret hashmap(vec::u8::hash, vec::u8::eq); } #[doc = "Construct a hashmap for int keys"] -fn new_int_hash<V: copy>() -> hashmap<int, V> { +fn int_hash<V: copy>() -> hashmap<int, V> { fn hash_int(&&x: int) -> uint { int::hash(x) } fn eq_int(&&a: int, &&b: int) -> bool { ret a == b; } - ret new_hashmap(hash_int, eq_int); + ret hashmap(hash_int, eq_int); } #[doc = "Construct a hashmap for uint keys"] -fn new_uint_hash<V: copy>() -> hashmap<uint, V> { +fn uint_hash<V: copy>() -> hashmap<uint, V> { fn hash_uint(&&x: uint) -> uint { uint::hash(x) } fn eq_uint(&&a: uint, &&b: uint) -> bool { ret a == b; } - ret new_hashmap(hash_uint, eq_uint); + ret hashmap(hash_uint, eq_uint); } #[doc = " @@ -346,7 +346,7 @@ mod tests { let eqer_str: map::eqfn<str> = str::eq; #debug("uint -> uint"); let hm_uu: map::hashmap<uint, uint> = - map::new_hashmap::<uint, uint>(hasher_uint, eqer_uint); + map::hashmap::<uint, uint>(hasher_uint, eqer_uint); assert (hm_uu.insert(10u, 12u)); assert (hm_uu.insert(11u, 13u)); assert (hm_uu.insert(12u, 14u)); @@ -362,7 +362,7 @@ mod tests { let twelve: str = "twelve"; #debug("str -> uint"); let hm_su: map::hashmap<str, uint> = - map::new_hashmap::<str, uint>(hasher_str, eqer_str); + map::hashmap::<str, uint>(hasher_str, eqer_str); assert (hm_su.insert("ten", 12u)); assert (hm_su.insert(eleven, 13u)); assert (hm_su.insert("twelve", 14u)); @@ -376,7 +376,7 @@ mod tests { assert (hm_su.get("twelve") == 12u); #debug("uint -> str"); let hm_us: map::hashmap<uint, str> = - map::new_hashmap::<uint, str>(hasher_uint, eqer_uint); + map::hashmap::<uint, str>(hasher_uint, eqer_uint); assert (hm_us.insert(10u, "twelve")); assert (hm_us.insert(11u, "thirteen")); assert (hm_us.insert(12u, "fourteen")); @@ -389,7 +389,7 @@ mod tests { assert (str::eq(hm_us.get(12u), "twelve")); #debug("str -> str"); let hm_ss: map::hashmap<str, str> = - map::new_hashmap::<str, str>(hasher_str, eqer_str); + map::hashmap::<str, str>(hasher_str, eqer_str); assert (hm_ss.insert(ten, "twelve")); assert (hm_ss.insert(eleven, "thirteen")); assert (hm_ss.insert(twelve, "fourteen")); @@ -417,7 +417,7 @@ mod tests { let hasher_uint: map::hashfn<uint> = uint_id; let eqer_uint: map::eqfn<uint> = eq_uint; let hm_uu: map::hashmap<uint, uint> = - map::new_hashmap::<uint, uint>(hasher_uint, eqer_uint); + map::hashmap::<uint, uint>(hasher_uint, eqer_uint); let i: uint = 0u; while i < num_to_insert { assert (hm_uu.insert(i, i * i)); @@ -444,7 +444,7 @@ mod tests { let hasher_str: map::hashfn<str> = str::hash; let eqer_str: map::eqfn<str> = str::eq; let hm_ss: map::hashmap<str, str> = - map::new_hashmap::<str, str>(hasher_str, eqer_str); + map::hashmap::<str, str>(hasher_str, eqer_str); i = 0u; while i < num_to_insert { assert hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u)); @@ -497,7 +497,7 @@ mod tests { let hasher: map::hashfn<uint> = hash; let eqer: map::eqfn<uint> = eq; let hm: map::hashmap<uint, uint> = - map::new_hashmap::<uint, uint>(hasher, eqer); + map::hashmap::<uint, uint>(hasher, eqer); let i: uint = 0u; while i < num_to_insert { assert (hm.insert(i, i * i)); @@ -560,7 +560,7 @@ mod tests { #[test] fn test_contains_key() { let key = "k"; - let map = map::new_hashmap::<str, str>(str::hash, str::eq); + let map = map::hashmap::<str, str>(str::hash, str::eq); assert (!map.contains_key(key)); map.insert(key, "val"); assert (map.contains_key(key)); @@ -569,7 +569,7 @@ mod tests { #[test] fn test_find() { let key = "k"; - let map = map::new_hashmap::<str, str>(str::hash, str::eq); + let map = map::hashmap::<str, str>(str::hash, str::eq); assert (option::is_none(map.find(key))); map.insert(key, "val"); assert (option::get(map.find(key)) == "val"); diff --git a/src/libstd/uv.rs b/src/libstd/uv.rs index 026a9edb6a8..f6f42de148a 100644 --- a/src/libstd/uv.rs +++ b/src/libstd/uv.rs @@ -131,17 +131,17 @@ fn loop_new() -> uv_loop unsafe { // all state goes here let handles: map::hashmap<[u8], *libc::c_void> = - map::new_bytes_hash(); + map::bytes_hash(); let id_to_handle: map::hashmap<[u8], uv_handle> = - map::new_bytes_hash(); + map::bytes_hash(); let after_cbs: map::hashmap<[u8], fn~(uv_handle)> = - map::new_bytes_hash(); + map::bytes_hash(); let close_callbacks: map::hashmap<[u8], fn~()> = - map::new_bytes_hash(); + map::bytes_hash(); let async_cbs: map::hashmap<[u8], fn~(uv_handle)> = - map::new_bytes_hash(); + map::bytes_hash(); let timer_cbs: map::hashmap<[u8], fn~(uv_handle)> = - map::new_bytes_hash(); + map::bytes_hash(); // the main loop that this task blocks on. // should have the same lifetime as the C libuv |
