Skip to content

Commit 75bd094

Browse files
committed
libstd: remove field days of time::Duration and change secs to type i64
Closes rust-lang#16466. The return type of `to_tuple_64`, `num_milliseconds` etc. has been change too, so this change is [breaking-change]
1 parent e052aa6 commit 75bd094

File tree

4 files changed

+124
-165
lines changed

4 files changed

+124
-165
lines changed

src/libstd/io/net/tcp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ impl TcpStream {
115115
let SocketAddr { ip, port } = addr;
116116
let addr = rtio::SocketAddr { ip: super::to_rtio(ip), port: port };
117117
LocalIo::maybe_raise(|io| {
118-
io.tcp_connect(addr, Some(timeout.num_milliseconds() as u64)).map(TcpStream::new)
118+
io.tcp_connect(addr, timeout.num_milliseconds().map(|ms| ms as u64))
119+
.map(TcpStream::new)
119120
}).map_err(IoError::from_rtio_error)
120121
}
121122

src/libstd/io/net/unix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ impl UnixStream {
7474
}
7575

7676
LocalIo::maybe_raise(|io| {
77-
let s = io.unix_connect(&path.to_c_str(), Some(timeout.num_milliseconds() as u64));
77+
let s = io.unix_connect(&path.to_c_str(),
78+
timeout.num_milliseconds().map(|ms| ms as u64));
7879
s.map(|p| UnixStream { obj: p })
7980
}).map_err(IoError::from_rtio_error)
8081
}

src/libstd/io/timer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use io::{IoResult, IoError};
2525
use kinds::Send;
2626
use boxed::Box;
2727
use rt::rtio::{IoFactory, LocalIo, RtioTimer, Callback};
28+
use option::Some;
2829

2930
/// A synchronous timer object
3031
///
@@ -225,9 +226,10 @@ impl Callback for TimerCallback {
225226
}
226227

227228
fn in_ms_u64(d: Duration) -> u64 {
228-
let ms = d.num_milliseconds();
229-
if ms < 0 { return 0 };
230-
return ms as u64;
229+
match d.num_milliseconds() {
230+
Some(ms) if ms >= 0 => ms as u64,
231+
_ => 0
232+
}
231233
}
232234

233235
#[cfg(test)]

0 commit comments

Comments
 (0)