Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PartialOrd and Ord implementation for std::net::SocketAddr #53863

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use slice;
/// assert_eq!(socket.port(), 8080);
/// assert_eq!(socket.is_ipv4(), true);
/// ```
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum SocketAddr {
/// An IPv4 socket address.
Expand Down Expand Up @@ -81,7 +81,7 @@ pub enum SocketAddr {
/// assert_eq!(socket.ip(), &Ipv4Addr::new(127, 0, 0, 1));
/// assert_eq!(socket.port(), 8080);
/// ```
#[derive(Copy)]
#[derive(Copy, PartialOrd, Ord)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SocketAddrV4 { inner: c::sockaddr_in }

Expand Down Expand Up @@ -111,7 +111,7 @@ pub struct SocketAddrV4 { inner: c::sockaddr_in }
/// assert_eq!(socket.ip(), &Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1));
/// assert_eq!(socket.port(), 8080);
/// ```
#[derive(Copy)]
#[derive(Copy, PartialOrd, Ord)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SocketAddrV6 { inner: c::sockaddr_in6 }

Expand Down
10 changes: 5 additions & 5 deletions src/libstd/sys/redox/net/netc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ pub type sa_family_t = u16;
pub const AF_INET: sa_family_t = 2;
pub const AF_INET6: sa_family_t = 23;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialOrd, Ord)]
#[repr(C)]
pub struct in_addr {
pub s_addr: in_addr_t,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialOrd, Ord)]
#[repr(align(4))]
#[repr(C)]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialOrd, Ord)]
#[repr(C)]
pub struct sockaddr {
pub sa_family: sa_family_t,
pub sa_data: [u8; 14],
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialOrd, Ord)]
#[repr(C)]
pub struct sockaddr_in {
pub sin_family: sa_family_t,
Expand All @@ -46,7 +46,7 @@ pub struct sockaddr_in {
pub sin_zero: [u8; 8],
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialOrd, Ord)]
#[repr(C)]
pub struct sockaddr_in6 {
pub sin6_family: sa_family_t,
Expand Down