|  | 
| 1 |  | -use crate::cmp::Ordering; | 
| 2 | 1 | use crate::fmt::{self, Write}; | 
| 3 |  | -use crate::hash; | 
| 4 | 2 | use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; | 
| 5 | 3 | 
 | 
| 6 | 4 | use super::display_buffer::DisplayBuffer; | 
| @@ -63,7 +61,7 @@ pub enum SocketAddr { | 
| 63 | 61 | /// assert_eq!(socket.ip(), &Ipv4Addr::new(127, 0, 0, 1)); | 
| 64 | 62 | /// assert_eq!(socket.port(), 8080); | 
| 65 | 63 | /// ``` | 
| 66 |  | -#[derive(Copy, Clone, Eq, PartialEq)] | 
|  | 64 | +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] | 
| 67 | 65 | #[stable(feature = "rust1", since = "1.0.0")] | 
| 68 | 66 | pub struct SocketAddrV4 { | 
| 69 | 67 |     ip: Ipv4Addr, | 
| @@ -96,7 +94,7 @@ pub struct SocketAddrV4 { | 
| 96 | 94 | /// assert_eq!(socket.ip(), &Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1)); | 
| 97 | 95 | /// assert_eq!(socket.port(), 8080); | 
| 98 | 96 | /// ``` | 
| 99 |  | -#[derive(Copy, Clone, Eq, PartialEq)] | 
|  | 97 | +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] | 
| 100 | 98 | #[stable(feature = "rust1", since = "1.0.0")] | 
| 101 | 99 | pub struct SocketAddrV6 { | 
| 102 | 100 |     ip: Ipv6Addr, | 
| @@ -644,48 +642,3 @@ impl fmt::Debug for SocketAddrV6 { | 
| 644 | 642 |         fmt::Display::fmt(self, fmt) | 
| 645 | 643 |     } | 
| 646 | 644 | } | 
| 647 |  | - | 
| 648 |  | -#[stable(feature = "socketaddr_ordering", since = "1.45.0")] | 
| 649 |  | -impl PartialOrd for SocketAddrV4 { | 
| 650 |  | -    #[inline] | 
| 651 |  | -    fn partial_cmp(&self, other: &SocketAddrV4) -> Option<Ordering> { | 
| 652 |  | -        Some(self.cmp(other)) | 
| 653 |  | -    } | 
| 654 |  | -} | 
| 655 |  | - | 
| 656 |  | -#[stable(feature = "socketaddr_ordering", since = "1.45.0")] | 
| 657 |  | -impl PartialOrd for SocketAddrV6 { | 
| 658 |  | -    #[inline] | 
| 659 |  | -    fn partial_cmp(&self, other: &SocketAddrV6) -> Option<Ordering> { | 
| 660 |  | -        Some(self.cmp(other)) | 
| 661 |  | -    } | 
| 662 |  | -} | 
| 663 |  | - | 
| 664 |  | -#[stable(feature = "socketaddr_ordering", since = "1.45.0")] | 
| 665 |  | -impl Ord for SocketAddrV4 { | 
| 666 |  | -    #[inline] | 
| 667 |  | -    fn cmp(&self, other: &SocketAddrV4) -> Ordering { | 
| 668 |  | -        self.ip().cmp(other.ip()).then(self.port().cmp(&other.port())) | 
| 669 |  | -    } | 
| 670 |  | -} | 
| 671 |  | - | 
| 672 |  | -#[stable(feature = "socketaddr_ordering", since = "1.45.0")] | 
| 673 |  | -impl Ord for SocketAddrV6 { | 
| 674 |  | -    #[inline] | 
| 675 |  | -    fn cmp(&self, other: &SocketAddrV6) -> Ordering { | 
| 676 |  | -        self.ip().cmp(other.ip()).then(self.port().cmp(&other.port())) | 
| 677 |  | -    } | 
| 678 |  | -} | 
| 679 |  | - | 
| 680 |  | -#[stable(feature = "rust1", since = "1.0.0")] | 
| 681 |  | -impl hash::Hash for SocketAddrV4 { | 
| 682 |  | -    fn hash<H: hash::Hasher>(&self, s: &mut H) { | 
| 683 |  | -        (self.port, self.ip).hash(s) | 
| 684 |  | -    } | 
| 685 |  | -} | 
| 686 |  | -#[stable(feature = "rust1", since = "1.0.0")] | 
| 687 |  | -impl hash::Hash for SocketAddrV6 { | 
| 688 |  | -    fn hash<H: hash::Hasher>(&self, s: &mut H) { | 
| 689 |  | -        (self.port, &self.ip, self.flowinfo, self.scope_id).hash(s) | 
| 690 |  | -    } | 
| 691 |  | -} | 
0 commit comments