Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prelude #3299

Merged
merged 2 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ A basic TCP echo server with Tokio:

```rust,no_run
use tokio::net::TcpListener;
use tokio::prelude::*;
use tokio::io::{AsyncReadExt, AsyncWriteExt};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/codec/length_delimited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//! Specifically, given the following:
//!
//! ```
//! use tokio::prelude::*;
//! use tokio::io::{AsyncRead, AsyncWrite};
//! use tokio_util::codec::{Framed, LengthDelimitedCodec};
//!
//! use futures::SinkExt;
Expand Down
3 changes: 1 addition & 2 deletions tokio-util/tests/framed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![warn(rust_2018_idioms)]

use tokio::prelude::*;
use tokio_stream::StreamExt;
use tokio_test::assert_ok;
use tokio_util::codec::{Decoder, Encoder, Framed, FramedParts};
Expand Down Expand Up @@ -52,7 +51,7 @@ impl Read for DontReadIntoThis {
}
}

impl AsyncRead for DontReadIntoThis {
impl tokio::io::AsyncRead for DontReadIntoThis {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
Expand Down
2 changes: 1 addition & 1 deletion tokio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ A basic TCP echo server with Tokio:

```rust,no_run
use tokio::net::TcpListener;
use tokio::prelude::*;
use tokio::io::{AsyncReadExt, AsyncWriteExt};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
18 changes: 8 additions & 10 deletions tokio/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,22 @@ use std::task::Poll::*;
/// the data to disk.
///
/// Reading and writing to a `File` is usually done using the convenience
/// methods found on the [`AsyncReadExt`] and [`AsyncWriteExt`] traits. Examples
/// import these traits through [the prelude].
/// methods found on the [`AsyncReadExt`] and [`AsyncWriteExt`] traits.
///
/// [std]: struct@std::fs::File
/// [`AsyncSeek`]: trait@crate::io::AsyncSeek
/// [`flush`]: fn@crate::io::AsyncWriteExt::flush
/// [`sync_all`]: fn@crate::fs::File::sync_all
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
/// [the prelude]: crate::prelude
///
/// # Examples
///
/// Create a new file and asynchronously write bytes to it:
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*; // for write_all()
/// use tokio::io::AsyncWriteExt; // for write_all()
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::create("foo.txt").await?;
Expand All @@ -67,7 +65,7 @@ use std::task::Poll::*;
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*; // for read_to_end()
/// use tokio::io::AsyncReadExt; // for read_to_end()
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::open("foo.txt").await?;
Expand Down Expand Up @@ -125,7 +123,7 @@ impl File {
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::AsyncReadExt;
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::open("foo.txt").await?;
Expand Down Expand Up @@ -169,7 +167,7 @@ impl File {
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::AsyncWriteExt;
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::create("foo.txt").await?;
Expand Down Expand Up @@ -221,7 +219,7 @@ impl File {
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::AsyncWriteExt;
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::create("foo.txt").await?;
Expand Down Expand Up @@ -256,7 +254,7 @@ impl File {
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::AsyncWriteExt;
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::create("foo.txt").await?;
Expand Down Expand Up @@ -294,7 +292,7 @@ impl File {
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::AsyncWriteExt;
///
/// # async fn dox() -> std::io::Result<()> {
/// let mut file = File::create("foo.txt").await?;
Expand Down
5 changes: 1 addition & 4 deletions tokio/src/io/util/async_read_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ cfg_io_util! {
/// [`AsyncRead`] types. Callers will tend to import this trait instead of
/// [`AsyncRead`].
///
/// As a convenience, this trait may be imported using the [`prelude`]:
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::{self, AsyncReadExt};
///
/// #[tokio::main]
/// async fn main() -> io::Result<()> {
Expand All @@ -60,7 +58,6 @@ cfg_io_util! {
/// See [module][crate::io] documentation for more details.
///
/// [`AsyncRead`]: AsyncRead
/// [`prelude`]: crate::prelude
pub trait AsyncReadExt: AsyncRead {
/// Creates a new `AsyncRead` instance that chains this stream with
/// `next`.
Expand Down
11 changes: 4 additions & 7 deletions tokio/src/io/util/async_seek_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ use crate::io::AsyncSeek;
use std::io::SeekFrom;

cfg_io_util! {
/// An extension trait which adds utility methods to [`AsyncSeek`] types.
///
/// As a convenience, this trait may be imported using the [`prelude`]:
/// An extension trait that adds utility methods to [`AsyncSeek`] types.
///
/// # Examples
///
/// ```
/// use std::io::{Cursor, SeekFrom};
/// use tokio::prelude::*;
/// use std::io::{self, Cursor, SeekFrom};
/// use tokio::io::{AsyncSeekExt, AsyncReadExt};
///
/// #[tokio::main]
/// async fn main() -> io::Result<()> {
Expand All @@ -32,7 +30,6 @@ cfg_io_util! {
/// See [module][crate::io] documentation for more details.
///
/// [`AsyncSeek`]: AsyncSeek
/// [`prelude`]: crate::prelude
pub trait AsyncSeekExt: AsyncSeek {
/// Creates a future which will seek an IO object, and then yield the
/// new position in the object and the object itself.
Expand All @@ -50,7 +47,7 @@ cfg_io_util! {
///
/// ```no_run
/// use tokio::fs::File;
/// use tokio::prelude::*;
/// use tokio::io::{AsyncSeekExt, AsyncReadExt};
///
/// use std::io::SeekFrom;
///
Expand Down
5 changes: 1 addition & 4 deletions tokio/src/io/util/async_write_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ cfg_io_util! {
/// [`AsyncWrite`] types. Callers will tend to import this trait instead of
/// [`AsyncWrite`].
///
/// As a convenience, this trait may be imported using the [`prelude`]:
///
/// ```no_run
/// use tokio::prelude::*;
/// use tokio::io::{self, AsyncWriteExt};
/// use tokio::fs::File;
///
/// #[tokio::main]
Expand All @@ -64,7 +62,6 @@ cfg_io_util! {
/// See [module][crate::io] documentation for more details.
///
/// [`AsyncWrite`]: AsyncWrite
/// [`prelude`]: crate::prelude
pub trait AsyncWriteExt: AsyncWrite {
/// Writes a buffer into this writer, returning how many bytes were
/// written.
Expand Down
4 changes: 1 addition & 3 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
//!
//! ```no_run
//! use tokio::net::TcpListener;
//! use tokio::prelude::*;
//! use tokio::io::{AsyncReadExt, AsyncWriteExt};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -363,8 +363,6 @@ pub mod net;
mod loom;
mod park;

pub mod prelude;

cfg_process! {
pub mod process;
}
Expand Down
8 changes: 3 additions & 5 deletions tokio/src/net/tcp/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ use std::task::{Context, Poll};
/// Borrowed read half of a [`TcpStream`], created by [`split`].
///
/// Reading from a `ReadHalf` is usually done using the convenience methods found on the
/// [`AsyncReadExt`] trait. Examples import this trait through [the prelude].
/// [`AsyncReadExt`] trait.
///
/// [`TcpStream`]: TcpStream
/// [`split`]: TcpStream::split()
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct ReadHalf<'a>(&'a TcpStream);

Expand All @@ -35,14 +34,13 @@ pub struct ReadHalf<'a>(&'a TcpStream);
/// shut down the TCP stream in the write direction.
///
/// Writing to an `WriteHalf` is usually done using the convenience methods found
/// on the [`AsyncWriteExt`] trait. Examples import this trait through [the prelude].
/// on the [`AsyncWriteExt`] trait.
///
/// [`TcpStream`]: TcpStream
/// [`split`]: TcpStream::split()
/// [`AsyncWrite`]: trait@crate::io::AsyncWrite
/// [`poll_shutdown`]: fn@crate::io::AsyncWrite::poll_shutdown
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct WriteHalf<'a>(&'a TcpStream);

Expand Down Expand Up @@ -101,7 +99,7 @@ impl ReadHalf<'_> {
///
/// ```no_run
/// use tokio::net::TcpStream;
/// use tokio::prelude::*;
/// use tokio::io::AsyncReadExt;
/// use std::error::Error;
///
/// #[tokio::main]
Expand Down
8 changes: 3 additions & 5 deletions tokio/src/net/tcp/split_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ use std::{fmt, io};
/// Owned read half of a [`TcpStream`], created by [`into_split`].
///
/// Reading from an `OwnedReadHalf` is usually done using the convenience methods found
/// on the [`AsyncReadExt`] trait. Examples import this trait through [the prelude].
/// on the [`AsyncReadExt`] trait.
///
/// [`TcpStream`]: TcpStream
/// [`into_split`]: TcpStream::into_split()
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct OwnedReadHalf {
inner: Arc<TcpStream>,
Expand All @@ -40,14 +39,13 @@ pub struct OwnedReadHalf {
/// will also shut down the write half of the TCP stream.
///
/// Writing to an `OwnedWriteHalf` is usually done using the convenience methods found
/// on the [`AsyncWriteExt`] trait. Examples import this trait through [the prelude].
/// on the [`AsyncWriteExt`] trait.
///
/// [`TcpStream`]: TcpStream
/// [`into_split`]: TcpStream::into_split()
/// [`AsyncWrite`]: trait@crate::io::AsyncWrite
/// [`poll_shutdown`]: fn@crate::io::AsyncWrite::poll_shutdown
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct OwnedWriteHalf {
inner: Arc<TcpStream>,
Expand Down Expand Up @@ -156,7 +154,7 @@ impl OwnedReadHalf {
///
/// ```no_run
/// use tokio::net::TcpStream;
/// use tokio::prelude::*;
/// use tokio::io::AsyncReadExt;
/// use std::error::Error;
///
/// #[tokio::main]
Expand Down
9 changes: 4 additions & 5 deletions tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@ cfg_net! {
///
/// Reading and writing to a `TcpStream` is usually done using the
/// convenience methods found on the [`AsyncReadExt`] and [`AsyncWriteExt`]
/// traits. Examples import these traits through [the prelude].
/// traits.
///
/// [`connect`]: method@TcpStream::connect
/// [accepting]: method@crate::net::TcpListener::accept
/// [listener]: struct@crate::net::TcpListener
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
/// [the prelude]: crate::prelude
///
/// # Examples
///
/// ```no_run
/// use tokio::net::TcpStream;
/// use tokio::prelude::*;
/// use tokio::io::AsyncWriteExt;
/// use std::error::Error;
///
/// #[tokio::main]
Expand Down Expand Up @@ -81,7 +80,7 @@ impl TcpStream {
///
/// ```no_run
/// use tokio::net::TcpStream;
/// use tokio::prelude::*;
/// use tokio::io::AsyncWriteExt;
/// use std::error::Error;
///
/// #[tokio::main]
Expand Down Expand Up @@ -648,7 +647,7 @@ impl TcpStream {
///
/// ```no_run
/// use tokio::net::TcpStream;
/// use tokio::prelude::*;
/// use tokio::io::AsyncReadExt;
/// use std::error::Error;
///
/// #[tokio::main]
Expand Down
6 changes: 2 additions & 4 deletions tokio/src/net/unix/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use std::task::{Context, Poll};
/// Borrowed read half of a [`UnixStream`], created by [`split`].
///
/// Reading from a `ReadHalf` is usually done using the convenience methods found on the
/// [`AsyncReadExt`] trait. Examples import this trait through [the prelude].
/// [`AsyncReadExt`] trait.
///
/// [`UnixStream`]: UnixStream
/// [`split`]: UnixStream::split()
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct ReadHalf<'a>(&'a UnixStream);

Expand All @@ -34,14 +33,13 @@ pub struct ReadHalf<'a>(&'a UnixStream);
/// shut down the UnixStream stream in the write direction.
///
/// Writing to an `WriteHalf` is usually done using the convenience methods found
/// on the [`AsyncWriteExt`] trait. Examples import this trait through [the prelude].
/// on the [`AsyncWriteExt`] trait.
///
/// [`UnixStream`]: UnixStream
/// [`split`]: UnixStream::split()
/// [`AsyncWrite`]: trait@crate::io::AsyncWrite
/// [`poll_shutdown`]: fn@crate::io::AsyncWrite::poll_shutdown
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct WriteHalf<'a>(&'a UnixStream);

Expand Down
7 changes: 2 additions & 5 deletions tokio/src/net/unix/split_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ use std::{fmt, io};
/// Owned read half of a [`UnixStream`], created by [`into_split`].
///
/// Reading from an `OwnedReadHalf` is usually done using the convenience methods found
/// on the [`AsyncReadExt`] trait. Examples import this trait through [the prelude].
/// on the [`AsyncReadExt`] trait.
///
/// [`UnixStream`]: crate::net::UnixStream
/// [`into_split`]: crate::net::UnixStream::into_split()
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct OwnedReadHalf {
inner: Arc<UnixStream>,
Expand All @@ -39,15 +38,13 @@ pub struct OwnedReadHalf {
/// Dropping the write half will also shut down the write half of the stream.
///
/// Writing to an `OwnedWriteHalf` is usually done using the convenience methods
/// found on the [`AsyncWriteExt`] trait. Examples import this trait through
/// [the prelude].
/// found on the [`AsyncWriteExt`] trait.
///
/// [`UnixStream`]: crate::net::UnixStream
/// [`into_split`]: crate::net::UnixStream::into_split()
/// [`AsyncWrite`]: trait@crate::io::AsyncWrite
/// [`poll_shutdown`]: fn@crate::io::AsyncWrite::poll_shutdown
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
/// [the prelude]: crate::prelude
#[derive(Debug)]
pub struct OwnedWriteHalf {
inner: Arc<UnixStream>,
Expand Down