about summary refs log tree commit diff
path: root/src/libsyntax/ext/deriving/mod.rs
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2014-02-21 21:33:23 -0800
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2014-02-21 21:33:23 -0800
commitd223dd1e57cc412aa2eff28e6604f86b9f013083 (patch)
treeaa8d3f01f77b0a74c024d1632df29d5a95f4724e /src/libsyntax/ext/deriving/mod.rs
parent0135b521ad38615e9a07aac54d9c22627af57ca4 (diff)
downloadrust-d223dd1e57cc412aa2eff28e6604f86b9f013083.tar.gz
rust-d223dd1e57cc412aa2eff28e6604f86b9f013083.zip
std: rewrite Hash to make it more generic
This patch merges IterBytes and Hash traits, which clears up the
confusion of using `#[deriving(IterBytes)]` to support hashing.
Instead, it now is much easier to use the new `#[deriving(Hash)]`
for making a type hashable with a stream hash.

Furthermore, it supports custom non-stream-based hashers, such as
if a value's hash was cached in a database.

This does not yet replace the old IterBytes-hash with this new
version.
Diffstat (limited to 'src/libsyntax/ext/deriving/mod.rs')
-rw-r--r--src/libsyntax/ext/deriving/mod.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index 7c686e5cd67..31ee99fbd26 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -26,6 +26,7 @@ pub mod clone;
 pub mod iter_bytes;
 pub mod encodable;
 pub mod decodable;
+pub mod hash;
 pub mod rand;
 pub mod to_str;
 pub mod show;
@@ -74,6 +75,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
                             "DeepClone" => expand!(clone::expand_deriving_deep_clone),
 
                             "IterBytes" => expand!(iter_bytes::expand_deriving_iter_bytes),
+                            "Hash" => expand!(hash::expand_deriving_hash),
 
                             "Encodable" => expand!(encodable::expand_deriving_encodable),
                             "Decodable" => expand!(decodable::expand_deriving_decodable),