chore: format code and enable rustfmt CI task (#1212)

This commit is contained in:
Carl Lerche
2019-06-27 00:05:01 -07:00
committed by GitHub
parent 1f47ed3dcc
commit ed4d4a5353
22 changed files with 94 additions and 60 deletions
+7 -6
View File
@@ -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)
}
+2 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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;
+7 -4
View File
@@ -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")
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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))
+4 -2
View File
@@ -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);