Skip to content

Commit ffc8826

Browse files
committed
Remove usage of std::num::Int
1 parent 30ea974 commit ffc8826

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/sys/socket/addr.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use errno::Errno;
44
use libc;
55
use std::{fmt, hash, mem, net, ptr};
66
use std::ffi::{CStr, OsStr};
7-
use std::num::Int;
87
use std::path::Path;
98
use std::os::unix::ffi::OsStrExt;
109

@@ -71,8 +70,8 @@ impl InetAddr {
7170
/// Gets the port number associated with this socket address
7271
pub fn port(&self) -> u16 {
7372
match *self {
74-
InetAddr::V6(ref sa) => Int::from_be(sa.sin6_port),
75-
InetAddr::V4(ref sa) => Int::from_be(sa.sin_port),
73+
InetAddr::V6(ref sa) => u16::from_be(sa.sin6_port),
74+
InetAddr::V4(ref sa) => u16::from_be(sa.sin_port),
7675
}
7776
}
7877

@@ -232,7 +231,7 @@ impl Ipv4Addr {
232231
}
233232

234233
pub fn octets(&self) -> [u8; 4] {
235-
let bits = Int::from_be(self.0.s_addr);
234+
let bits = u32::from_be(self.0.s_addr);
236235
[(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8]
237236
}
238237

@@ -302,14 +301,14 @@ impl Ipv6Addr {
302301

303302
/// Return the eight 16-bit segments that make up this address
304303
pub fn segments(&self) -> [u16; 8] {
305-
[Int::from_be(self.0.s6_addr[0]),
306-
Int::from_be(self.0.s6_addr[1]),
307-
Int::from_be(self.0.s6_addr[2]),
308-
Int::from_be(self.0.s6_addr[3]),
309-
Int::from_be(self.0.s6_addr[4]),
310-
Int::from_be(self.0.s6_addr[5]),
311-
Int::from_be(self.0.s6_addr[6]),
312-
Int::from_be(self.0.s6_addr[7])]
304+
[u16::from_be(self.0.s6_addr[0]),
305+
u16::from_be(self.0.s6_addr[1]),
306+
u16::from_be(self.0.s6_addr[2]),
307+
u16::from_be(self.0.s6_addr[3]),
308+
u16::from_be(self.0.s6_addr[4]),
309+
u16::from_be(self.0.s6_addr[5]),
310+
u16::from_be(self.0.s6_addr[6]),
311+
u16::from_be(self.0.s6_addr[7])]
313312
}
314313

315314
pub fn to_std(&self) -> net::Ipv6Addr {

src/sys/time.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{fmt, ops};
2-
use std::num::Int;
32
use libc::{time_t, suseconds_t};
43

54
#[repr(C)]

test/sys/test_socket.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use nix::sys::socket::{InetAddr, UnixAddr, getsockname};
22
use std::{mem, net};
3-
use std::num::Int;
43
use std::path::Path;
54
use std::str::FromStr;
65
use std::os::unix::io::AsRawFd;
@@ -13,8 +12,11 @@ pub fn test_inetv4_addr_to_sock_addr() {
1312

1413
match addr {
1514
InetAddr::V4(addr) => {
16-
assert_eq!(addr.sin_addr.s_addr, 0x7f000001.to_be());
17-
assert_eq!(addr.sin_port, 3000.to_be());
15+
let ip: u32 = 0x7f000001;
16+
let port: u16 = 3000;
17+
18+
assert_eq!(addr.sin_addr.s_addr, ip.to_be());
19+
assert_eq!(addr.sin_port, port.to_be());
1820
}
1921
_ => panic!("nope"),
2022
}

0 commit comments

Comments
 (0)