diff --git a/examples/print-file.rs b/examples/print-file.rs index b204a469..49d02448 100644 --- a/examples/print-file.rs +++ b/examples/print-file.rs @@ -4,7 +4,7 @@ use std::env::args; -use async_std::{fs, io, prelude::*, task}; +use async_std::{fs::File, io, prelude::*, task}; const LEN: usize = 4 * 1024 * 1024; // 4 Mb @@ -12,7 +12,7 @@ fn main() -> io::Result<()> { let path = args().nth(1).expect("missing path argument"); task::block_on(async { - let mut file = fs::File::open(&path).await?; + let mut file = File::open(&path).await?; let mut stdout = io::stdout(); let mut buf = vec![0u8; LEN]; @@ -23,7 +23,6 @@ fn main() -> io::Result<()> { // If this is the end of file, clean up and return. if n == 0 { stdout.flush().await?; - file.close().await?; return Ok(()); } diff --git a/examples/tcp-client.rs b/examples/tcp-client.rs index dd613db5..83e6a325 100644 --- a/examples/tcp-client.rs +++ b/examples/tcp-client.rs @@ -14,11 +14,11 @@ #![feature(async_await)] -use async_std::{io, net, prelude::*, task}; +use async_std::{io, net::TcpStream, prelude::*, task}; fn main() -> io::Result<()> { task::block_on(async { - let mut stream = net::TcpStream::connect("127.0.0.1:8080").await?; + let mut stream = TcpStream::connect("127.0.0.1:8080").await?; println!("Connected to {}", &stream.peer_addr()?); let msg = "hello world"; diff --git a/examples/tcp-echo.rs b/examples/tcp-echo.rs index 498bb03c..2c192cfa 100644 --- a/examples/tcp-echo.rs +++ b/examples/tcp-echo.rs @@ -8,9 +8,10 @@ #![feature(async_await)] -use async_std::{io, net, prelude::*, task}; +use async_std::net::{TcpListener, TcpStream}; +use async_std::{io, prelude::*, task}; -async fn process(stream: net::TcpStream) -> io::Result<()> { +async fn process(stream: TcpStream) -> io::Result<()> { println!("Accepted from: {}", stream.peer_addr()?); let (reader, writer) = &mut (&stream, &stream); @@ -21,7 +22,7 @@ async fn process(stream: net::TcpStream) -> io::Result<()> { fn main() -> io::Result<()> { task::block_on(async { - let listener = net::TcpListener::bind("127.0.0.1:8080").await?; + let listener = TcpListener::bind("127.0.0.1:8080").await?; println!("Listening on {}", listener.local_addr()?); let mut incoming = listener.incoming(); diff --git a/examples/udp-client.rs b/examples/udp-client.rs index 5e5bbcad..defc6613 100644 --- a/examples/udp-client.rs +++ b/examples/udp-client.rs @@ -14,11 +14,11 @@ #![feature(async_await)] -use async_std::{io, net, task}; +use async_std::{io, net::UdpSocket, task}; fn main() -> io::Result<()> { task::block_on(async { - let socket = net::UdpSocket::bind("127.0.0.1:8081").await?; + let socket = UdpSocket::bind("127.0.0.1:8081").await?; println!("Listening on {}", socket.local_addr()?); let msg = "hello world"; diff --git a/examples/udp-echo.rs b/examples/udp-echo.rs index 3ee6b284..5bb0bb47 100644 --- a/examples/udp-echo.rs +++ b/examples/udp-echo.rs @@ -8,11 +8,11 @@ #![feature(async_await)] -use async_std::{io, net, task}; +use async_std::{io, net::UdpSocket, task}; fn main() -> io::Result<()> { task::block_on(async { - let socket = net::UdpSocket::bind("127.0.0.1:8080").await?; + let socket = UdpSocket::bind("127.0.0.1:8080").await?; let mut buf = vec![0u8; 1024]; println!("Listening on {}", socket.local_addr()?);