From 3ecaa6d91cef271b4c079a2e28bc3270280bcee6 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sat, 23 Nov 2019 08:24:03 -0800 Subject: docs: improve tokio::io API documentation (#1815) Adds method level documentation for `tokio::io`. --- examples/proxy.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'examples/proxy.rs') diff --git a/examples/proxy.rs b/examples/proxy.rs index 4314d1b9..48f8f057 100644 --- a/examples/proxy.rs +++ b/examples/proxy.rs @@ -22,12 +22,13 @@ #![warn(rust_2018_idioms)] -use futures::{future::try_join, FutureExt}; -use std::{env, error::Error}; -use tokio::{ - io::AsyncReadExt, - net::{TcpListener, TcpStream}, -}; +use tokio::io; +use tokio::net::{TcpListener, TcpStream}; + +use futures::future::try_join; +use futures::FutureExt; +use std::env; +use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box> { @@ -58,8 +59,8 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: String) -> Result<(), Box< let (mut ri, mut wi) = inbound.split(); let (mut ro, mut wo) = outbound.split(); - let client_to_server = ri.copy(&mut wo); - let server_to_client = ro.copy(&mut wi); + let client_to_server = io::copy(&mut ri, &mut wo); + let server_to_client = io::copy(&mut ro, &mut wi); try_join(client_to_server, server_to_client).await?; -- cgit v1.2.3