Skip to content

Commit 65088b8

Browse files
committed
introduce std + default features
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
1 parent 4770201 commit 65088b8

File tree

9 files changed

+207
-138
lines changed

9 files changed

+207
-138
lines changed

Cargo.toml

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,55 @@ features = ["docs"]
2121
rustdoc-args = ["--cfg", "feature=\"docs\""]
2222

2323
[features]
24-
default = ["core"]
25-
docs = ["unstable", "attributes"]
26-
unstable = ["broadcaster"]
27-
attributes = ["async-attributes"]
28-
core = []
24+
default = [
25+
"std",
26+
"async-task",
27+
"crossbeam-deque",
28+
"futures-timer",
29+
"kv-log-macro",
30+
"log",
31+
"mio",
32+
"mio-uds",
33+
"num_cpus",
34+
"pin-project-lite",
35+
]
36+
docs = ["unstable"]
37+
unstable = ["default", "broadcaster"]
38+
std = [
39+
"async-macros",
40+
"crossbeam-channel",
41+
"crossbeam-utils",
42+
"futures-core",
43+
"futures-io",
44+
"futures-timer",
45+
"memchr",
46+
"once_cell",
47+
"pin-project-lite",
48+
"pin-utils",
49+
"slab",
50+
]
2951

3052
[dependencies]
3153
async-attributes = { version = "1.1.0", optional = true }
32-
async-macros = "1.0.0"
33-
async-task = "1.0.0"
54+
async-macros = { version = "1.0.0", optional = true }
55+
async-task = { version = "1.0.0", optional = true }
3456
broadcaster = { version = "0.2.6", optional = true, default-features = false, features = ["default-channels"] }
35-
crossbeam-channel = "0.3.9"
36-
crossbeam-deque = "0.7.1"
37-
crossbeam-utils = "0.6.6"
38-
futures-core = "0.3.0"
39-
futures-io = "0.3.0"
40-
futures-timer = "1.0.2"
41-
kv-log-macro = "1.0.4"
42-
log = { version = "0.4.8", features = ["kv_unstable"] }
43-
memchr = "2.2.1"
44-
mio = "0.6.19"
45-
mio-uds = "0.6.7"
46-
num_cpus = "1.10.1"
47-
once_cell = "1.2.0"
48-
pin-project-lite = "0.1"
49-
pin-utils = "0.1.0-alpha.4"
50-
slab = "0.4.2"
57+
crossbeam-channel = { version = "0.3.9", optional = true }
58+
crossbeam-deque = { version = "0.7.1", optional = true }
59+
crossbeam-utils = { version = "0.6.6", optional = true }
60+
futures-core = { version = "0.3.0", optional = true }
61+
futures-io = { version = "0.3.0", optional = true }
62+
futures-timer = { version = "1.0.2", optional = true }
63+
kv-log-macro = { version = "1.0.4", optional = true }
64+
log = { version = "0.4.8", features = ["kv_unstable"], optional = true }
65+
memchr = { version = "2.2.1", optional = true }
66+
mio = { version = "0.6.19", optional = true }
67+
mio-uds = { version = "0.6.7", optional = true }
68+
num_cpus = { version = "1.10.1", optional = true }
69+
once_cell = { version = "1.2.0", optional = true }
70+
pin-project-lite = { version = "0.1", optional = true }
71+
pin-utils = { version = "0.1.0-alpha.4", optional = true }
72+
slab = { version = "0.4.2", optional = true }
5173

5274
[dev-dependencies]
5375
femme = "1.2.0"

src/io/mod.rs

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -269,48 +269,54 @@
269269
//! [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
270270
//! [`.unwrap()`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.unwrap
271271
272-
#[doc(inline)]
273-
pub use std::io::{Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom};
272+
cfg_std! {
273+
#[doc(inline)]
274+
pub use std::io::{Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom};
274275

275-
pub use buf_read::{BufRead, Lines};
276-
pub use buf_reader::BufReader;
277-
pub use buf_writer::BufWriter;
278-
pub use copy::copy;
279-
pub use cursor::Cursor;
280-
pub use empty::{empty, Empty};
281-
pub use read::Read;
282-
pub use repeat::{repeat, Repeat};
283-
pub use seek::Seek;
284-
pub use sink::{sink, Sink};
285-
pub use stderr::{stderr, Stderr};
286-
pub use stdin::{stdin, Stdin};
287-
pub use stdout::{stdout, Stdout};
288-
pub use timeout::timeout;
289-
pub use write::Write;
276+
pub use buf_read::{BufRead, Lines};
277+
pub use buf_reader::BufReader;
278+
pub use buf_writer::BufWriter;
279+
pub use copy::copy;
280+
pub use cursor::Cursor;
281+
pub use empty::{empty, Empty};
282+
pub use read::Read;
283+
pub use repeat::{repeat, Repeat};
284+
pub use seek::Seek;
285+
pub use sink::{sink, Sink};
286+
pub use write::Write;
290287

291-
// For use in the print macros.
292-
#[doc(hidden)]
293-
pub use stdio::{_eprint, _print};
288+
pub mod prelude;
294289

295-
pub mod prelude;
290+
pub(crate) mod buf_read;
291+
pub(crate) mod read;
292+
pub(crate) mod seek;
293+
pub(crate) mod write;
296294

297-
pub(crate) mod buf_read;
298-
pub(crate) mod read;
299-
pub(crate) mod seek;
300-
pub(crate) mod write;
295+
mod buf_reader;
296+
mod buf_writer;
297+
mod copy;
298+
mod cursor;
299+
mod empty;
300+
mod repeat;
301+
mod sink;
302+
}
303+
304+
cfg_default! {
305+
// For use in the print macros.
306+
#[doc(hidden)]
307+
pub use stdio::{_eprint, _print};
301308

302-
mod buf_reader;
303-
mod buf_writer;
304-
mod copy;
305-
mod cursor;
306-
mod empty;
307-
mod repeat;
308-
mod sink;
309-
mod stderr;
310-
mod stdin;
311-
mod stdio;
312-
mod stdout;
313-
mod timeout;
309+
pub use stderr::{stderr, Stderr};
310+
pub use stdin::{stdin, Stdin};
311+
pub use stdout::{stdout, Stdout};
312+
pub use timeout::timeout;
313+
314+
mod timeout;
315+
mod stderr;
316+
mod stdin;
317+
mod stdio;
318+
mod stdout;
319+
}
314320

315321
cfg_unstable! {
316322
pub use stderr::StderrLock;

src/lib.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! # Async version of the Rust standard library
22
//!
33
//! `async-std` is a foundation of portable Rust software, a set of minimal and battle-tested
4-
//! shared abstractions for the [broader Rust ecosystem][crates.io]. It offers core types, like
4+
//! shared abstractions for the [broader Rust ecosystem][crates.io]. It offers std types, like
55
//! [`Future`] and [`Stream`], library-defined [operations on language primitives](#primitives),
66
//! [standard macros](#macros), [I/O] and [multithreading], among [many other things][other].
77
//!
@@ -158,7 +158,6 @@
158158
//! features = ["unstable"]
159159
//! ```
160160
//!
161-
<<<<<<< HEAD
162161
//! Items marked with
163162
//! <span
164163
//! class="module-item stab portability"
@@ -173,16 +172,15 @@
173172
//! ```
174173
//!
175174
//! Additionally it's possible to only use the core traits and combinators by
176-
//! only enabling the `core` Cargo feature:
175+
//! only enabling the `std` Cargo feature:
177176
//!
178177
//! ```toml
179178
//! [dependencies.async-std]
180179
//! version = "0.99"
181180
//! default-features = false
182-
//! features = ["core"]
181+
//! features = ["std"]
183182
//! ```
184183
185-
#![cfg(feature = "default")]
186184
#![cfg_attr(feature = "docs", feature(doc_cfg))]
187185
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
188186
#![allow(clippy::mutex_atomic, clippy::module_inception)]
@@ -199,16 +197,22 @@ mod utils;
199197
#[doc(inline)]
200198
pub use async_attributes::{main, test};
201199

202-
pub mod fs;
203-
pub mod future;
204-
pub mod io;
205-
pub mod net;
206-
pub mod os;
207-
pub mod path;
208-
pub mod prelude;
209-
pub mod stream;
210-
pub mod sync;
211-
pub mod task;
200+
cfg_std! {
201+
pub mod future;
202+
pub mod io;
203+
pub mod os;
204+
pub mod prelude;
205+
pub mod stream;
206+
pub mod sync;
207+
pub mod task;
208+
mod macros;
209+
}
210+
211+
cfg_default! {
212+
pub mod fs;
213+
pub mod path;
214+
pub mod net;
215+
}
212216

213217
cfg_unstable! {
214218
pub mod pin;
@@ -224,5 +228,3 @@ cfg_unstable! {
224228
#[doc(inline)]
225229
pub use std::{write, writeln};
226230
}
227-
228-
mod macros;

src/os/unix/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! Platform-specific extensions for Unix platforms.
22
3-
pub mod fs;
4-
pub mod io;
5-
pub mod net;
3+
cfg_std! {
4+
pub mod io;
5+
}
6+
7+
cfg_default! {
8+
pub mod fs;
9+
pub mod net;
10+
}

src/os/windows/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
//! Platform-specific extensions for Windows.
22
3-
pub mod io;
3+
cfg_std! {
4+
pub mod io;
5+
}

src/prelude.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,39 @@
1111
//! use async_std::prelude::*;
1212
//! ```
1313
14-
#[doc(no_inline)]
15-
pub use crate::future::Future;
16-
#[doc(no_inline)]
17-
pub use crate::stream::Stream;
18-
#[doc(no_inline)]
19-
pub use crate::task_local;
14+
cfg_std! {
15+
#[doc(no_inline)]
16+
pub use crate::future::Future;
17+
#[doc(no_inline)]
18+
pub use crate::stream::Stream;
2019

21-
#[doc(inline)]
22-
pub use crate::future::future::FutureExt;
23-
#[doc(inline)]
24-
pub use crate::stream::stream::StreamExt;
20+
#[doc(inline)]
21+
pub use crate::future::future::FutureExt;
22+
#[doc(inline)]
23+
pub use crate::stream::stream::StreamExt;
24+
#[doc(no_inline)]
25+
pub use crate::io::BufRead as _;
26+
#[doc(no_inline)]
27+
pub use crate::io::Read as _;
28+
#[doc(no_inline)]
29+
pub use crate::io::Seek as _;
30+
#[doc(no_inline)]
31+
pub use crate::io::Write as _;
2532

26-
#[doc(no_inline)]
27-
pub use crate::io::BufRead as _;
28-
#[doc(no_inline)]
29-
pub use crate::io::Read as _;
30-
#[doc(no_inline)]
31-
pub use crate::io::Seek as _;
32-
#[doc(no_inline)]
33-
pub use crate::io::Write as _;
33+
#[doc(no_inline)]
34+
pub use crate::io::prelude::BufReadExt as _;
35+
#[doc(no_inline)]
36+
pub use crate::io::prelude::ReadExt as _;
37+
#[doc(no_inline)]
38+
pub use crate::io::prelude::SeekExt as _;
39+
#[doc(no_inline)]
40+
pub use crate::io::prelude::WriteExt as _;
41+
}
3442

35-
#[doc(no_inline)]
36-
pub use crate::io::prelude::BufReadExt as _;
37-
#[doc(no_inline)]
38-
pub use crate::io::prelude::ReadExt as _;
39-
#[doc(no_inline)]
40-
pub use crate::io::prelude::SeekExt as _;
41-
#[doc(no_inline)]
42-
pub use crate::io::prelude::WriteExt as _;
43+
// cfg_default! {
44+
// #[doc(no_inline)]
45+
// pub use crate::task_local;
46+
// }
4347

4448
cfg_unstable! {
4549
#[doc(no_inline)]

src/sync/waker_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use std::cell::UnsafeCell;
88
use std::ops::{Deref, DerefMut};
99
use std::sync::atomic::{AtomicUsize, Ordering};
1010

11+
use std::task::{Context, Waker};
12+
1113
use crossbeam_utils::Backoff;
1214
use slab::Slab;
1315

14-
use crate::task::{Context, Waker};
15-
1616
/// Set when the entry list is locked.
1717
#[allow(clippy::identity_op)]
1818
const LOCKED: usize = 1 << 0;

0 commit comments

Comments
 (0)