Skip to content

Commit cc9e078

Browse files
Merge #160
160: add io::prelude r=stjepang a=yoshuawuyts I was working on some async io code earlier, and ended up writing: ```rust use async_std::io::{BufReader, BufRead, Read}; ``` It took a bit of trial and error to get the right traits in scope, and I kind of wished I had `io::prelude` available so it would *just work*. Which is why this patch adds `io::prelude`. I guess I'm kind of circling back on the idea of only having a single prelude; but overall I think this feels more intuitive. Thanks! ## Screenshots ![Screenshot_2019-09-08 async_std io - Rust](https://user-images.githubusercontent.com/2467194/64481454-8e2f8500-d1dc-11e9-9299-7a82b7dbb031.png) ![Screenshot_2019-09-08 async_std io prelude - Rust](https://user-images.githubusercontent.com/2467194/64481455-8e2f8500-d1dc-11e9-9d20-1e90fabccaf4.png) ![Screenshot_2019-09-08 std io prelude - Rust](https://user-images.githubusercontent.com/2467194/64481509-bfa85080-d1dc-11e9-9965-be7d0d84b551.png) Co-authored-by: Yoshua Wuyts <[email protected]>
2 parents 98d9284 + ec1f33f commit cc9e078

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/io/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
//! # Ok(()) }) }
2121
//! ```
2222
23+
pub mod prelude;
24+
2325
#[doc(inline)]
2426
pub use std::io::{Error, ErrorKind, Result, SeekFrom};
2527

src/io/prelude.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! The async I/O Prelude
2+
//!
3+
//! The purpose of this module is to alleviate imports of many common I/O traits
4+
//! by adding a glob import to the top of I/O heavy modules:
5+
//!
6+
//! ```
7+
//! # #![allow(unused_imports)]
8+
//! use async_std::io::prelude::*;
9+
//! ```
10+
11+
#[doc(no_inline)]
12+
pub use super::BufRead as _;
13+
#[doc(no_inline)]
14+
pub use super::Read as _;
15+
#[doc(no_inline)]
16+
pub use super::Seek as _;
17+
#[doc(no_inline)]
18+
pub use super::Write as _;

0 commit comments

Comments
 (0)