Skip to content

Commit caf50e6

Browse files
author
Stjepan Glavina
committed
Formatting
1 parent fdf0e3a commit caf50e6

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

examples/print-file.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use std::env::args;
66

7-
use async_std::{fs, io, prelude::*, task};
7+
use async_std::{fs::File, io, prelude::*, task};
88

99
const LEN: usize = 4 * 1024 * 1024; // 4 Mb
1010

1111
fn main() -> io::Result<()> {
1212
let path = args().nth(1).expect("missing path argument");
1313

1414
task::block_on(async {
15-
let mut file = fs::File::open(&path).await?;
15+
let mut file = File::open(&path).await?;
1616
let mut stdout = io::stdout();
1717
let mut buf = vec![0u8; LEN];
1818

@@ -23,7 +23,6 @@ fn main() -> io::Result<()> {
2323
// If this is the end of file, clean up and return.
2424
if n == 0 {
2525
stdout.flush().await?;
26-
file.close().await?;
2726
return Ok(());
2827
}
2928

examples/tcp-client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
1515
#![feature(async_await)]
1616

17-
use async_std::{io, net, prelude::*, task};
17+
use async_std::{io, net::TcpStream, prelude::*, task};
1818

1919
fn main() -> io::Result<()> {
2020
task::block_on(async {
21-
let mut stream = net::TcpStream::connect("127.0.0.1:8080").await?;
21+
let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
2222
println!("Connected to {}", &stream.peer_addr()?);
2323

2424
let msg = "hello world";

examples/tcp-echo.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
99
#![feature(async_await)]
1010

11-
use async_std::{io, net, prelude::*, task};
11+
use async_std::net::{TcpListener, TcpStream};
12+
use async_std::{io, prelude::*, task};
1213

13-
async fn process(stream: net::TcpStream) -> io::Result<()> {
14+
async fn process(stream: TcpStream) -> io::Result<()> {
1415
println!("Accepted from: {}", stream.peer_addr()?);
1516

1617
let (reader, writer) = &mut (&stream, &stream);
@@ -21,7 +22,7 @@ async fn process(stream: net::TcpStream) -> io::Result<()> {
2122

2223
fn main() -> io::Result<()> {
2324
task::block_on(async {
24-
let listener = net::TcpListener::bind("127.0.0.1:8080").await?;
25+
let listener = TcpListener::bind("127.0.0.1:8080").await?;
2526
println!("Listening on {}", listener.local_addr()?);
2627

2728
let mut incoming = listener.incoming();

examples/udp-client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
1515
#![feature(async_await)]
1616

17-
use async_std::{io, net, task};
17+
use async_std::{io, net::UdpSocket, task};
1818

1919
fn main() -> io::Result<()> {
2020
task::block_on(async {
21-
let socket = net::UdpSocket::bind("127.0.0.1:8081").await?;
21+
let socket = UdpSocket::bind("127.0.0.1:8081").await?;
2222
println!("Listening on {}", socket.local_addr()?);
2323

2424
let msg = "hello world";

examples/udp-echo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
99
#![feature(async_await)]
1010

11-
use async_std::{io, net, task};
11+
use async_std::{io, net::UdpSocket, task};
1212

1313
fn main() -> io::Result<()> {
1414
task::block_on(async {
15-
let socket = net::UdpSocket::bind("127.0.0.1:8080").await?;
15+
let socket = UdpSocket::bind("127.0.0.1:8080").await?;
1616
let mut buf = vec![0u8; 1024];
1717

1818
println!("Listening on {}", socket.local_addr()?);

0 commit comments

Comments
 (0)