File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -74,10 +74,13 @@ pub struct Ipv4Addr {
7474 octets : [ u8 ; 4 ] ,
7575}
7676
77+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
7778impl Hash for Ipv4Addr {
7879 fn hash < H : Hasher > ( & self , state : & mut H ) {
7980 // Hashers are often more efficient at hashing a fixed-width integer
80- // than a bytestring, so convert before hashing.
81+ // than a bytestring, so convert before hashing. We don't use to_bits()
82+ // here as that involves a byteswap on little-endian machines, which are
83+ // more common than big-endian machines.
8184 u32:: from_le_bytes ( self . octets ) . hash ( state) ;
8285 }
8386}
@@ -164,10 +167,13 @@ pub struct Ipv6Addr {
164167 octets : [ u8 ; 16 ] ,
165168}
166169
170+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
167171impl Hash for Ipv6Addr {
168172 fn hash < H : Hasher > ( & self , state : & mut H ) {
169173 // Hashers are often more efficient at hashing a fixed-width integer
170- // than a bytestring, so convert before hashing.
174+ // than a bytestring, so convert before hashing. We don't use to_bits()
175+ // here as that involves byteswaps on little-endian machines, which are
176+ // more common than big-endian machines.
171177 u128:: from_le_bytes ( self . octets ) . hash ( state) ;
172178 }
173179}
You can’t perform that action at this time.
0 commit comments