From caf50e69cfbb45e4d6c09d4a4c3b66477f34184e Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Mon, 12 Aug 2019 12:44:57 +0200 Subject: [PATCH] Formatting --- examples/print-file.rs | 5 ++--- examples/tcp-client.rs | 4 ++-- examples/tcp-echo.rs | 7 ++++--- examples/udp-client.rs | 4 ++-- examples/udp-echo.rs | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/print-file.rs b/examples/print-file.rs index b204a46..49d0244 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 dd613db..83e6a32 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 498bb03..2c192cf 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 5e5bbca..defc661 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 3ee6b28..5bb0bb4 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()?);