Change net::Incoming signature to match std. (#89)

std's `Incoming` iterator yields `TcpStream` instances. This patch
updates the `Incoming` future to match this signature.

This changes the yielded value from `(TcpStream, SocketAddr)` ->
`TcpStream`.
This commit is contained in:
Carl Lerche
2018-01-30 15:01:34 -06:00
committed by Alex Crichton
parent f4ec9a6360
commit ae627db266
18 changed files with 31 additions and 28 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ fn echo_server() {
(expected, t2)
});
let clients = srv.incoming().take(2).map(|e| e.0).collect();
let clients = srv.incoming().take(2).collect();
let copied = clients.and_then(|clients| {
let mut clients = clients.into_iter();
let a = BufReader::new(clients.next().unwrap());
+1 -1
View File
@@ -32,7 +32,7 @@ fn chain_clients() {
s3.write_all(b"baz").unwrap();
});
let clients = srv.incoming().map(|e| e.0).take(3);
let clients = srv.incoming().take(3);
let copied = clients.collect().and_then(|clients| {
let mut clients = clients.into_iter();
let a = clients.next().unwrap();
+1 -1
View File
@@ -41,7 +41,7 @@ fn echo_server() {
let clients = srv.incoming();
let client = clients.into_future().map(|e| e.0.unwrap()).map_err(|e| e.0);
let halves = client.map(|s| s.0.split());
let halves = client.map(|s| s.split());
let copied = halves.and_then(|(a, b)| copy(a, b));
let (amt, _, _) = t!(copied.wait());
+1 -1
View File
@@ -21,7 +21,7 @@ fn hammer() {
let addr = t!(srv.local_addr());
let mine = TcpStream::connect(&addr);
let theirs = srv.incoming().into_future()
.map(|(s, _)| s.unwrap().0)
.map(|(s, _)| s.unwrap())
.map_err(|(s, _)| s);
let (mine, theirs) = t!(mine.join(theirs).wait());
+1 -1
View File
@@ -28,7 +28,7 @@ fn limit() {
s1.write_all(b"foo bar baz").unwrap();
});
let clients = srv.incoming().map(|e| e.0).take(1);
let clients = srv.incoming().take(1);
let copied = clients.collect().and_then(|clients| {
let mut clients = clients.into_iter();
let a = clients.next().unwrap();
+1 -1
View File
@@ -59,7 +59,7 @@ fn echo() {
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap();
let addr = listener.local_addr().unwrap();
let pool_inner = pool.clone();
let srv = listener.incoming().for_each(move |(socket, _)| {
let srv = listener.incoming().for_each(move |socket| {
let (sink, stream) = socket.framed(LineCodec).split();
pool_inner.execute(sink.send_all(stream).map(|_| ()).map_err(|_| ())).unwrap();
Ok(())
+1 -1
View File
@@ -42,7 +42,7 @@ fn echo_server() {
});
let future = srv.incoming()
.map(|s| s.0.split())
.map(|s| s.split())
.map(|(a, b)| copy(a, b).map(|_| ()))
.buffered(10)
.take(2)
+2 -2
View File
@@ -43,7 +43,7 @@ fn accept() {
let (tx, rx) = channel();
let client = srv.incoming().map(move |t| {
tx.send(()).unwrap();
t.0
t
}).into_future().map_err(|e| e.0);
assert!(rx.try_recv().is_err());
let t = thread::spawn(move || {
@@ -71,7 +71,7 @@ fn accept2() {
let (tx, rx) = channel();
let client = srv.incoming().map(move |t| {
tx.send(()).unwrap();
t.0
t
}).into_future().map_err(|e| e.0);
assert!(rx.try_recv().is_err());