]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
e9174d1e SL |
11 | #![unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear", |
12 | issue = "27713")] | |
9cc50fc6 SL |
13 | #![rustc_deprecated(since = "1.7.0", reason = "support moved to std::hash")] |
14 | #![allow(deprecated)] | |
62682a34 | 15 | |
1a4d82fc JJ |
16 | use clone::Clone; |
17 | use default::Default; | |
18 | use hash; | |
85aaf69f | 19 | use marker; |
1a4d82fc | 20 | |
9cc50fc6 | 21 | pub use hash::HashState; |
1a4d82fc JJ |
22 | |
23 | /// A structure which is a factory for instances of `Hasher` which implement the | |
24 | /// default trait. | |
25 | /// | |
c1a9b12d | 26 | /// This struct is 0-sized and does not need construction. |
85aaf69f | 27 | pub struct DefaultState<H>(marker::PhantomData<H>); |
1a4d82fc JJ |
28 | |
29 | impl<H: Default + hash::Hasher> HashState for DefaultState<H> { | |
30 | type Hasher = H; | |
31 | fn hasher(&self) -> H { Default::default() } | |
32 | } | |
33 | ||
34 | impl<H> Clone for DefaultState<H> { | |
85aaf69f | 35 | fn clone(&self) -> DefaultState<H> { DefaultState(marker::PhantomData) } |
1a4d82fc JJ |
36 | } |
37 | ||
38 | impl<H> Default for DefaultState<H> { | |
85aaf69f | 39 | fn default() -> DefaultState<H> { DefaultState(marker::PhantomData) } |
1a4d82fc | 40 | } |