summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2015-04-01 20:35:24 -0700
committerCarl Lerche <me@carllerche.com>2015-04-01 20:35:24 -0700
commitffc8826dfe446b20a4c435e143cddf4b7ca34bad (patch)
tree2986506b9fa5d91334b97d3f5e06282e18b926dc
parent30ea974431848851e3ed7d4c7adfd42930d78eda (diff)
downloadnix-ffc8826dfe446b20a4c435e143cddf4b7ca34bad.zip
Remove usage of std::num::Int
-rw-r--r--src/sys/socket/addr.rs23
-rw-r--r--src/sys/time.rs1
-rw-r--r--test/sys/test_socket.rs8
3 files changed, 16 insertions, 16 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 85a74d93..34028246 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -4,7 +4,6 @@ use errno::Errno;
use libc;
use std::{fmt, hash, mem, net, ptr};
use std::ffi::{CStr, OsStr};
-use std::num::Int;
use std::path::Path;
use std::os::unix::ffi::OsStrExt;
@@ -71,8 +70,8 @@ impl InetAddr {
/// Gets the port number associated with this socket address
pub fn port(&self) -> u16 {
match *self {
- InetAddr::V6(ref sa) => Int::from_be(sa.sin6_port),
- InetAddr::V4(ref sa) => Int::from_be(sa.sin_port),
+ InetAddr::V6(ref sa) => u16::from_be(sa.sin6_port),
+ InetAddr::V4(ref sa) => u16::from_be(sa.sin_port),
}
}
@@ -232,7 +231,7 @@ impl Ipv4Addr {
}
pub fn octets(&self) -> [u8; 4] {
- let bits = Int::from_be(self.0.s_addr);
+ let bits = u32::from_be(self.0.s_addr);
[(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8]
}
@@ -302,14 +301,14 @@ impl Ipv6Addr {
/// Return the eight 16-bit segments that make up this address
pub fn segments(&self) -> [u16; 8] {
- [Int::from_be(self.0.s6_addr[0]),
- Int::from_be(self.0.s6_addr[1]),
- Int::from_be(self.0.s6_addr[2]),
- Int::from_be(self.0.s6_addr[3]),
- Int::from_be(self.0.s6_addr[4]),
- Int::from_be(self.0.s6_addr[5]),
- Int::from_be(self.0.s6_addr[6]),
- Int::from_be(self.0.s6_addr[7])]
+ [u16::from_be(self.0.s6_addr[0]),
+ u16::from_be(self.0.s6_addr[1]),
+ u16::from_be(self.0.s6_addr[2]),
+ u16::from_be(self.0.s6_addr[3]),
+ u16::from_be(self.0.s6_addr[4]),
+ u16::from_be(self.0.s6_addr[5]),
+ u16::from_be(self.0.s6_addr[6]),
+ u16::from_be(self.0.s6_addr[7])]
}
pub fn to_std(&self) -> net::Ipv6Addr {
diff --git a/src/sys/time.rs b/src/sys/time.rs
index f66605c7..5c39d987 100644
--- a/src/sys/time.rs
+++ b/src/sys/time.rs
@@ -1,5 +1,4 @@
use std::{fmt, ops};
-use std::num::Int;
use libc::{time_t, suseconds_t};
#[repr(C)]
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index f2ebfe69..1983e7b5 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -1,6 +1,5 @@
use nix::sys::socket::{InetAddr, UnixAddr, getsockname};
use std::{mem, net};
-use std::num::Int;
use std::path::Path;
use std::str::FromStr;
use std::os::unix::io::AsRawFd;
@@ -13,8 +12,11 @@ pub fn test_inetv4_addr_to_sock_addr() {
match addr {
InetAddr::V4(addr) => {
- assert_eq!(addr.sin_addr.s_addr, 0x7f000001.to_be());
- assert_eq!(addr.sin_port, 3000.to_be());
+ let ip: u32 = 0x7f000001;
+ let port: u16 = 3000;
+
+ assert_eq!(addr.sin_addr.s_addr, ip.to_be());
+ assert_eq!(addr.sin_port, port.to_be());
}
_ => panic!("nope"),
}