File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 11//! Platform-agnostic support types.
22
3+ #[ cfg( feature = "extra_traits" ) ]
4+ use core:: hash:: Hash ;
35use core:: mem:: MaybeUninit ;
46
57use crate :: prelude:: * ;
@@ -30,6 +32,24 @@ impl<T: Copy> fmt::Debug for Padding<T> {
3032 }
3133}
3234
35+ /// Do nothing when hashing to ignore the existence of padding fields.
36+ #[ cfg( feature = "extra_traits" ) ]
37+ impl < T : Copy > Hash for Padding < T > {
38+ fn hash < H : hash:: Hasher > ( & self , _state : & mut H ) { }
39+ }
40+
41+ /// Padding fields are all equal, regardless of what is inside them, so they do not affect anything.
42+ #[ cfg( feature = "extra_traits" ) ]
43+ impl < T : Copy > PartialEq for Padding < T > {
44+ fn eq ( & self , _other : & Self ) -> bool {
45+ true
46+ }
47+ }
48+
49+ /// Mark that `Padding` implements `Eq` so that it can be used in types that implement it.
50+ #[ cfg( feature = "extra_traits" ) ]
51+ impl < T : Copy > Eq for Padding < T > { }
52+
3353/// The default repr type used for C style enums in Rust.
3454#[ cfg( target_env = "msvc" ) ]
3555#[ allow( unused) ]
You can’t perform that action at this time.
0 commit comments