Update futures dependency

This commit is contained in:
Alex Crichton
2017-08-24 08:16:04 -07:00
parent 77d9a1aa4f
commit e8617ea1fc
6 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ scoped-tls = "0.1.0"
slab = "0.3" slab = "0.3"
iovec = "0.1" iovec = "0.1"
tokio-io = "0.1" tokio-io = "0.1"
futures = "0.1.14" futures = "0.1.15"
[dev-dependencies] [dev-dependencies]
env_logger = { version = "0.4", default-features = false } env_logger = { version = "0.4", default-features = false }
+3 -3
View File
@@ -68,7 +68,7 @@ fn main() {
// Model the read portion of this socket by mapping an infinite // Model the read portion of this socket by mapping an infinite
// iterator to each line off the socket. This "loop" is then // iterator to each line off the socket. This "loop" is then
// terminated with an error once we hit EOF on the socket. // terminated with an error once we hit EOF on the socket.
let iter = stream::iter(iter::repeat(()).map(Ok::<(), Error>)); let iter = stream::iter_ok::<_, Error>(iter::repeat(()));
let socket_reader = iter.fold(reader, move |reader, _| { let socket_reader = iter.fold(reader, move |reader, _| {
// Read a line off the socket, failing if we're at EOF // Read a line off the socket, failing if we're at EOF
let line = io::read_until(reader, b'\n', Vec::new()); let line = io::read_until(reader, b'\n', Vec::new());
@@ -96,11 +96,11 @@ fn main() {
.filter(|&(&k, _)| k != addr) .filter(|&(&k, _)| k != addr)
.map(|(_, v)| v); .map(|(_, v)| v);
for tx in iter { for tx in iter {
tx.send(format!("{}: {}", addr, msg)).unwrap(); tx.unbounded_send(format!("{}: {}", addr, msg)).unwrap();
} }
} else { } else {
let tx = conns.get_mut(&addr).unwrap(); let tx = conns.get_mut(&addr).unwrap();
tx.send("You didn't send valid UTF-8.".to_string()).unwrap(); tx.unbounded_send("You didn't send valid UTF-8.".to_string()).unwrap();
} }
reader reader
}) })
+3 -3
View File
@@ -50,8 +50,8 @@ fn main() {
fn write(socket: TcpStream) -> IoFuture<()> { fn write(socket: TcpStream) -> IoFuture<()> {
static BUF: &'static [u8] = &[0; 64 * 1024]; static BUF: &'static [u8] = &[0; 64 * 1024];
let iter = iter::repeat(()).map(|()| Ok(())); let iter = iter::repeat(());
stream::iter(iter).fold(socket, |socket, ()| { Box::new(stream::iter_ok(iter).fold(socket, |socket, ()| {
tokio_io::io::write_all(socket, BUF).map(|(socket, _)| socket) tokio_io::io::write_all(socket, BUF).map(|(socket, _)| socket)
}).map(|_| ()).boxed() }).map(|_| ()))
} }
+1
View File
@@ -10,6 +10,7 @@
//! [low level details]: https://tokio.rs/docs/going-deeper-tokio/core-low-level/ //! [low level details]: https://tokio.rs/docs/going-deeper-tokio/core-low-level/
#![deprecated(note = "moved to the `tokio-io` crate")] #![deprecated(note = "moved to the `tokio-io` crate")]
#![allow(deprecated)]
use std::io; use std::io;
+1 -1
View File
@@ -308,7 +308,7 @@ impl TcpStream {
Ok(tcp) => TcpStream::new(tcp, handle), Ok(tcp) => TcpStream::new(tcp, handle),
Err(e) => TcpStreamNewState::Error(e), Err(e) => TcpStreamNewState::Error(e),
}; };
state.boxed() Box::new(state)
} }
/// Test whether this socket is ready to be read or not. /// Test whether this socket is ready to be read or not.
+1 -1
View File
@@ -583,7 +583,7 @@ impl Remote {
lp.notify(msg); lp.notify(msg);
} }
None => { None => {
match mpsc::UnboundedSender::send(&self.tx, msg) { match self.tx.unbounded_send(msg) {
Ok(()) => {} Ok(()) => {}
// TODO: this error should punt upwards and we should // TODO: this error should punt upwards and we should