Skip to main content

announce_std/
hash.rs

1//! announce mocks of `hash` traits. Generated from newer-type-std's copies.
2
3#[allow(unused_imports)]
4use announce::announce;
5
6/// announce mock of [`::core::hash::Hash`]: invoke `Hash!` to receive its definition.
7///
8/// The real trait is available under the same path in the type namespace
9/// (from rustc 1.94, through a glob re-export, since the macro namespace holds this
10/// trampoline).
11#[announce(mock = ::core::hash::Hash)]
12pub trait Hash {
13    fn hash<H>(&self, state: &mut H)
14    where
15        H: ::core::hash::Hasher;
16}
17
18#[cfg(not(announce_std_rust_1_94))]
19/// Fallback for rustc < 1.94: a blanket subtrait of [`::core::hash::Hash`], usable in bounds.
20pub trait Hash: ::core::hash::Hash {}
21#[cfg(not(announce_std_rust_1_94))]
22impl<__T: ?::core::marker::Sized + ::core::hash::Hash> Hash for __T {}
23
24/// announce mock of [`::core::hash::Hasher`]: invoke `Hasher!` to receive its definition.
25///
26/// The real trait is re-exported under the same path.
27#[announce(mock = ::core::hash::Hasher)]
28pub trait Hasher {
29    fn finish(&self) -> ::core::primitive::u64;
30    fn write(&mut self, bytes: &[::core::primitive::u8]);
31    fn write_u8(&mut self, i: ::core::primitive::u8) {
32        ::core::unimplemented!()
33    }
34    fn write_u16(&mut self, i: ::core::primitive::u16) {
35        ::core::unimplemented!()
36    }
37    fn write_u32(&mut self, i: ::core::primitive::u32) {
38        ::core::unimplemented!()
39    }
40    fn write_u64(&mut self, i: ::core::primitive::u64) {
41        ::core::unimplemented!()
42    }
43    fn write_u128(&mut self, i: ::core::primitive::u128) {
44        ::core::unimplemented!()
45    }
46    fn write_usize(&mut self, i: ::core::primitive::usize) {
47        ::core::unimplemented!()
48    }
49    fn write_i8(&mut self, i: ::core::primitive::i8) {
50        ::core::unimplemented!()
51    }
52    fn write_i16(&mut self, i: ::core::primitive::i16) {
53        ::core::unimplemented!()
54    }
55    fn write_i32(&mut self, i: ::core::primitive::i32) {
56        ::core::unimplemented!()
57    }
58    fn write_i64(&mut self, i: ::core::primitive::i64) {
59        ::core::unimplemented!()
60    }
61    fn write_i128(&mut self, i: ::core::primitive::i128) {
62        ::core::unimplemented!()
63    }
64    fn write_isize(&mut self, i: ::core::primitive::isize) {
65        ::core::unimplemented!()
66    }
67}
68
69#[doc(no_inline)]
70pub use ::core::hash::Hasher;
71
72/// announce mock of [`::core::hash::BuildHasher`]: invoke `BuildHasher!` to receive its definition.
73///
74/// The real trait is re-exported under the same path.
75///
76/// `hash_one` is not part of the mock: it is stable only since Rust 1.71 and announce-std
77/// supports older compilers. To hash a value, go through [`::core::hash::Hash::hash`] with
78/// `build_hasher()`: `x.hash(&mut b.build_hasher())`, then `finish()` on the hasher.
79#[announce(mock = ::core::hash::BuildHasher)]
80pub trait BuildHasher {
81    type Hasher: ::core::hash::Hasher;
82    fn build_hasher(&self) -> Self::Hasher;
83}
84
85#[doc(no_inline)]
86pub use ::core::hash::BuildHasher;
87
88// Real traits whose name is also a derive macro: explicit names shadow glob
89// imports per namespace, so this glob supplies the *trait* while the announce
90// trampoline above keeps the *macro* namespace. Before rustc 1.94 the glob
91// breaks the trampoline's resolution, so it is only emitted from 1.94 on.
92#[cfg(announce_std_rust_1_94)]
93#[doc(hidden)]
94pub mod __real {
95
96    pub use ::core::hash::Hash;
97}
98#[cfg(announce_std_rust_1_94)]
99#[doc(no_inline)]
100pub use self::__real::*;