summaryrefslogtreecommitdiffstats
path: root/tokio
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-06-27 00:05:01 -0700
committerGitHub <noreply@github.com>2019-06-27 00:05:01 -0700
commited4d4a5353d07d2428072965ea23c9a6eba5d87d (patch)
treee18da92f826a22eb253cc5d41149457a547910a3 /tokio
parent1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3 (diff)
chore: format code and enable rustfmt CI task (#1212)
Diffstat (limited to 'tokio')
-rw-r--r--tokio/src/io/async_read_ext.rs13
-rw-r--r--tokio/src/io/async_write_ext.rs3
-rw-r--r--tokio/src/io/mod.rs2
-rw-r--r--tokio/src/io/read_exact.rs11
-rw-r--r--tokio/src/net.rs2
-rw-r--r--tokio/tests/io_copy.rs2
-rw-r--r--tokio/tests/io_read.rs2
-rw-r--r--tokio/tests/io_read_exact.rs6
8 files changed, 24 insertions, 17 deletions
diff --git a/tokio/src/io/async_read_ext.rs b/tokio/src/io/async_read_ext.rs
index cca0906a..62b239a8 100644
--- a/tokio/src/io/async_read_ext.rs
+++ b/tokio/src/io/async_read_ext.rs
@@ -6,7 +6,6 @@ use tokio_io::{AsyncRead, AsyncWrite};
/// An extension trait which adds utility methods to `AsyncRead` types.
pub trait AsyncReadExt: AsyncRead {
-
/// Copy all data from `self` into the provided `AsyncWrite`.
///
/// The returned future will copy all the bytes read from `reader` into the
@@ -24,9 +23,9 @@ pub trait AsyncReadExt: AsyncRead {
/// unimplemented!();
/// ```
fn copy<'a, W>(&'a mut self, dst: &'a mut W) -> Copy<'a, Self, W>
- where
- Self: Unpin,
- W: AsyncWrite + Unpin + ?Sized,
+ where
+ Self: Unpin,
+ W: AsyncWrite + Unpin + ?Sized,
{
copy(self, dst)
}
@@ -42,7 +41,8 @@ pub trait AsyncReadExt: AsyncRead {
/// unimplemented!();
/// ```
fn read<'a>(&'a mut self, dst: &'a mut [u8]) -> Read<'a, Self>
- where Self: Unpin,
+ where
+ Self: Unpin,
{
read(self, dst)
}
@@ -55,7 +55,8 @@ pub trait AsyncReadExt: AsyncRead {
/// unimplemented!();
/// ```
fn read_exact<'a>(&'a mut self, dst: &'a mut [u8]) -> ReadExact<'a, Self>
- where Self: Unpin,
+ where
+ Self: Unpin,
{
read_exact(self, dst)
}
diff --git a/tokio/src/io/async_write_ext.rs b/tokio/src/io/async_write_ext.rs
index 759dac99..ffb5794f 100644
--- a/tokio/src/io/async_write_ext.rs
+++ b/tokio/src/io/async_write_ext.rs
@@ -15,7 +15,8 @@ pub trait AsyncWriteExt: AsyncWrite {
/// unimplemented!();
/// ````
fn write<'a>(&'a mut self, src: &'a [u8]) -> Write<'a, Self>
- where Self: Unpin,
+ where
+ Self: Unpin,
{
write(self, src)
}
diff --git a/tokio/src/io/mod.rs b/tokio/src/io/mod.rs
index 20730811..5fb4951c 100644
--- a/tokio/src/io/mod.rs
+++ b/tokio/src/io/mod.rs
@@ -40,8 +40,8 @@ mod async_read_ext;
mod async_write_ext;
mod copy;
mod read;
-mod write;
mod read_exact;
+mod write;
pub use self::async_read_ext::AsyncReadExt;
pub use self::async_write_ext::AsyncWriteExt;
diff --git a/tokio/src/io/read_exact.rs b/tokio/src/io/read_exact.rs
index c8b2f884..32320814 100644
--- a/tokio/src/io/read_exact.rs
+++ b/tokio/src/io/read_exact.rs
@@ -11,11 +11,15 @@ use tokio_io::AsyncRead;
/// Created by the [`read_exact`] function.
///
/// [`read_exact`]: fn.read_exact.html
-pub(crate) fn read_exact<'a, A>(reader: &'a mut A, buf: &'a mut[u8]) -> ReadExact<'a, A>
+pub(crate) fn read_exact<'a, A>(reader: &'a mut A, buf: &'a mut [u8]) -> ReadExact<'a, A>
where
- A: AsyncRead + Unpin + ?Sized
+ A: AsyncRead + Unpin + ?Sized,
{
- ReadExact { reader, buf, pos: 0 }
+ ReadExact {
+ reader,
+ buf,
+ pos: 0,
+ }
}
/// Creates a future which will read exactly enough bytes to fill `buf`,
@@ -29,7 +33,6 @@ pub struct ReadExact<'a, A: ?Sized> {
pos: usize,
}
-
fn eof() -> io::Error {
io::Error::new(io::ErrorKind::UnexpectedEof, "early eof")
}
diff --git a/tokio/src/net.rs b/tokio/src/net.rs
index 872ec22a..896bca3d 100644
--- a/tokio/src/net.rs
+++ b/tokio/src/net.rs
@@ -58,7 +58,7 @@ pub mod udp {
//! [`Send`]: struct.Send.html
//! [`RecvFrom`]: struct.RecvFrom.html
//! [`SendTo`]: struct.SendTo.html
- pub use tokio_udp::{UdpSocket, Recv, Send, RecvFrom, SendTo};
+ pub use tokio_udp::{Recv, RecvFrom, Send, SendTo, UdpSocket};
}
#[cfg(feature = "udp")]
pub use self::udp::UdpSocket;
diff --git a/tokio/tests/io_copy.rs b/tokio/tests/io_copy.rs
index 0179cfb7..2fac7e85 100644
--- a/tokio/tests/io_copy.rs
+++ b/tokio/tests/io_copy.rs
@@ -1,7 +1,7 @@
#![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
-use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt};
+use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite};
use tokio_test::assert_ok;
use bytes::BytesMut;
diff --git a/tokio/tests/io_read.rs b/tokio/tests/io_read.rs
index b1fc42c4..0ec2bef3 100644
--- a/tokio/tests/io_read.rs
+++ b/tokio/tests/io_read.rs
@@ -22,7 +22,7 @@ async fn read() {
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
assert_eq!(0, self.poll_cnt);
- self.poll_cnt +=1 ;
+ self.poll_cnt += 1;
buf[0..11].copy_from_slice(b"hello world");
Poll::Ready(Ok(11))
diff --git a/tokio/tests/io_read_exact.rs b/tokio/tests/io_read_exact.rs
index 1e3ab4ed..eae7435f 100644
--- a/tokio/tests/io_read_exact.rs
+++ b/tokio/tests/io_read_exact.rs
@@ -18,7 +18,7 @@ async fn read_exact() {
fn poll_read(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
- buf: &mut [u8]
+ buf: &mut [u8],
) -> Poll<io::Result<usize>> {
let me = &mut *self;
let len = buf.len();
@@ -29,7 +29,9 @@ async fn read_exact() {
}
let mut buf = Box::new([0; 8]);
- let mut rd = Rd { val: b"hello world" };
+ let mut rd = Rd {
+ val: b"hello world",
+ };
let n = assert_ok!(rd.read_exact(&mut buf[..]).await);
assert_eq!(n, 8);