diff options
| author | Orson Peters <orsonpeters@gmail.com> | 2024-08-11 01:28:30 +0200 |
|---|---|---|
| committer | Orson Peters <orsonpeters@gmail.com> | 2024-08-11 01:28:30 +0200 |
| commit | a04a1e464f6c83e1472d3b20141fabd631a5c178 (patch) | |
| tree | b5cce63fcca5ab2bba879a5f0ec57a0bca4aee94 /library/core/src/net | |
| parent | ba620344301aaa3b2733575a0696cdfd877edbdf (diff) | |
Fix stability annotation and expand comment
Diffstat (limited to 'library/core/src/net')
| -rw-r--r-- | library/core/src/net/ip_addr.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index 6dc8018d80d..495e9ade383 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -74,10 +74,13 @@ pub struct Ipv4Addr { octets: [u8; 4], } +#[stable(feature = "rust1", since = "1.0.0")] impl Hash for Ipv4Addr { fn hash<H: Hasher>(&self, state: &mut H) { // Hashers are often more efficient at hashing a fixed-width integer - // than a bytestring, so convert before hashing. + // than a bytestring, so convert before hashing. We don't use to_bits() + // here as that involves a byteswap on little-endian machines, which are + // more common than big-endian machines. u32::from_le_bytes(self.octets).hash(state); } } @@ -164,10 +167,13 @@ pub struct Ipv6Addr { octets: [u8; 16], } +#[stable(feature = "rust1", since = "1.0.0")] impl Hash for Ipv6Addr { fn hash<H: Hasher>(&self, state: &mut H) { // Hashers are often more efficient at hashing a fixed-width integer - // than a bytestring, so convert before hashing. + // than a bytestring, so convert before hashing. We don't use to_bits() + // here as that involves byteswaps on little-endian machines, which are + // more common than big-endian machines. u128::from_le_bytes(self.octets).hash(state); } } |
