Skip to content

Commit 1b6e815

Browse files
pin-utils & goodbye extern crate
1 parent 3fdcfc1 commit 1b6e815

File tree

129 files changed

+148
-372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+148
-372
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@
2626

2727
## Usage
2828

29-
First, add this to your `Cargo.toml`:
29+
Add this to your `Cargo.toml`:
3030

3131
```toml
3232
[dependencies]
3333
futures-preview = "0.3.0-alpha.2"
3434
```
3535

36-
Next, add this to your crate:
36+
Now, you can use futures-rs:
3737

3838
```rust
39-
extern crate futures; // Note: It's not `futures_preview`
40-
41-
use futures::future::Future;
39+
use futures::future::Future; // Note: It's not `futures_preview`
4240
```
4341

4442
### Feature `std`

futures-channel/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ futures-core-preview = { path = "../futures-core", version = "0.3.0-alpha.2", de
2525

2626
[dev-dependencies]
2727
futures-preview = { path = "../futures", version = "0.3.0-alpha.2", default-features = true }
28+
pin-utils = "0.1.0-alpha.1"

futures-channel/benches/sync_mpsc.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
#![feature(test, futures_api, pin, arbitrary_self_types)]
22

3-
#[macro_use]
4-
extern crate futures;
5-
extern crate test;
6-
7-
use futures::task::{self, Wake, LocalWaker};
3+
use futures::ready;
4+
use futures::channel::mpsc::{self, Sender, UnboundedSender};
85
use futures::executor::LocalPool;
96
use futures::prelude::*;
10-
use futures::channel::mpsc::{
11-
unbounded,
12-
channel,
13-
Sender,
14-
UnboundedSender,
15-
};
16-
7+
use futures::task::{self, Wake, LocalWaker};
178
use std::mem::PinMut;
189
use std::sync::Arc;
1910
use test::Bencher;
@@ -41,7 +32,7 @@ fn noop_cx(f: impl FnOnce(&mut task::Context)) {
4132
fn unbounded_1_tx(b: &mut Bencher) {
4233
noop_cx(|cx| {
4334
b.iter(|| {
44-
let (tx, mut rx) = unbounded();
35+
let (tx, mut rx) = mpsc::unbounded();
4536

4637
// 1000 iterations to avoid measuring overhead of initialization
4738
// Result should be divided by 1000
@@ -64,7 +55,7 @@ fn unbounded_1_tx(b: &mut Bencher) {
6455
fn unbounded_100_tx(b: &mut Bencher) {
6556
noop_cx(|cx| {
6657
b.iter(|| {
67-
let (tx, mut rx) = unbounded();
58+
let (tx, mut rx) = mpsc::unbounded();
6859

6960
let tx: Vec<_> = (0..100).map(|_| tx.clone()).collect();
7061

@@ -86,7 +77,7 @@ fn unbounded_100_tx(b: &mut Bencher) {
8677
fn unbounded_uncontended(b: &mut Bencher) {
8778
noop_cx(|cx| {
8879
b.iter(|| {
89-
let (tx, mut rx) = unbounded();
80+
let (tx, mut rx) = mpsc::unbounded();
9081

9182
for i in 0..1000 {
9283
UnboundedSender::unbounded_send(&tx, i).expect("send");
@@ -127,7 +118,7 @@ impl Stream for TestSender {
127118
fn bounded_1_tx(b: &mut Bencher) {
128119
noop_cx(|cx| {
129120
b.iter(|| {
130-
let (tx, mut rx) = channel(0);
121+
let (tx, mut rx) = mpsc::channel(0);
131122

132123
let mut tx = TestSender { tx, last: 0 };
133124

@@ -146,7 +137,7 @@ fn bounded_100_tx(b: &mut Bencher) {
146137
noop_cx(|cx| {
147138
b.iter(|| {
148139
// Each sender can send one item after specified capacity
149-
let (tx, mut rx) = channel(0);
140+
let (tx, mut rx) = mpsc::channel(0);
150141

151142
let mut tx: Vec<_> = (0..100).map(|_| {
152143
TestSender {

futures-channel/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212

1313
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures_channel")]
1414

15-
#[cfg(feature = "std")]
16-
extern crate std;
17-
18-
extern crate futures_core;
19-
2015
macro_rules! if_std {
2116
($($i:item)*) => ($(
2217
#[cfg(feature = "std")]

futures-channel/tests/channel.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#![feature(async_await, await_macro, futures_api)]
22

3-
extern crate futures;
4-
3+
use futures::channel::mpsc;
4+
use futures::executor::block_on;
5+
use futures::future::poll_fn;
6+
use futures::prelude::*;
57
use std::sync::atomic::*;
68
use std::thread;
79

8-
use futures::prelude::*;
9-
use futures::future::poll_fn;
10-
use futures::executor::block_on;
11-
use futures::channel::mpsc;
12-
1310
#[test]
1411
fn sequence() {
1512
let (tx, rx) = mpsc::channel(1);

futures-channel/tests/mpsc-close.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
extern crate futures;
2-
3-
use std::thread;
4-
5-
use futures::prelude::*;
61
use futures::channel::mpsc::*;
72
use futures::executor::block_on;
3+
use futures::prelude::*;
4+
use std::thread;
85

96
#[test]
107
fn smoke() {

futures-channel/tests/mpsc.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
#![feature(futures_api, async_await, await_macro, pin)]
22

3-
#[macro_use]
4-
extern crate futures;
5-
6-
use std::thread;
7-
use std::sync::{Arc, Mutex};
8-
use std::sync::atomic::{AtomicUsize, Ordering};
9-
10-
use futures::prelude::*;
113
use futures::future::poll_fn;
12-
use futures::channel::mpsc;
13-
use futures::channel::oneshot;
4+
use futures::channel::{mpsc, oneshot};
145
use futures::executor::{block_on, block_on_stream};
6+
use futures::prelude::*;
7+
use pin_utils::pin_mut;
8+
use std::sync::{Arc, Mutex};
9+
use std::sync::atomic::{AtomicUsize, Ordering};
10+
use std::thread;
1511

1612
trait AssertSend: Send {}
1713
impl AssertSend for mpsc::Sender<i32> {}

futures-channel/tests/oneshot.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#![feature(futures_api, arbitrary_self_types, pin)]
22

3-
extern crate futures;
4-
3+
use futures::channel::oneshot::*;
4+
use futures::executor::block_on;
5+
use futures::future::poll_fn;
6+
use futures::task;
7+
use futures::prelude::*;
58
use std::mem::PinMut;
69
use std::sync::mpsc;
710
use std::thread;
811

9-
use futures::future::poll_fn;
10-
use futures::prelude::*;
11-
use futures::task;
12-
use futures::channel::oneshot::*;
13-
use futures::executor::block_on;
14-
1512
#[test]
1613
fn smoke_poll() {
1714
let (mut tx, rx) = channel::<u32>();

futures-core/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures_core")]
1111

12-
#[cfg(feature = "std")]
13-
extern crate std;
14-
15-
#[cfg(feature = "either")]
16-
extern crate either;
17-
1812
#[doc(hidden)] pub use crate::future::Future;
1913
#[doc(hidden)] pub use crate::future::TryFuture;
2014

futures-executor/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ futures-util-preview = { path = "../futures-util", version = "0.3.0-alpha.2", de
2626
futures-channel-preview = { path = "../futures-channel", version = "0.3.0-alpha.2", default-features = false}
2727
num_cpus = { version = "1.0", optional = true }
2828
lazy_static = { version = "1.0", optional = true }
29+
pin-utils = "0.1.0-alpha.1"
2930

3031
[dev-dependencies]
3132
futures-preview = { path = "../futures", version = "0.3.0-alpha.2" }

futures-executor/benches/poll.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#![feature(test, pin, arbitrary_self_types, futures_api)]
22

3-
extern crate futures;
4-
extern crate test;
5-
6-
use futures::prelude::*;
7-
use futures::task::{self, Waker, LocalWaker, Wake, local_waker_from_nonlocal};
83
use futures::executor::LocalPool;
9-
4+
use futures::task::{self, Waker, LocalWaker, Wake, local_waker_from_nonlocal};
5+
use futures::prelude::*;
106
use std::marker::Unpin;
117
use std::mem::PinMut;
128
use std::sync::Arc;

futures-executor/benches/thread_notify.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
#![feature(test, futures_api, pin, arbitrary_self_types)]
22

3-
extern crate futures;
4-
extern crate test;
5-
3+
use futures::executor::block_on;
4+
use futures::task::{self, Waker};
5+
use futures::prelude::*;
66
use std::marker::Unpin;
77
use std::mem::PinMut;
8-
9-
use futures::prelude::*;
10-
use futures::task::{self, Waker};
11-
use futures::executor::block_on;
12-
138
use test::Bencher;
149

1510
#[bench]

futures-executor/src/enter.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub struct EnterError {
2626
/// completing task execution:
2727
///
2828
/// ```rust
29-
/// # extern crate futures;
3029
/// # use futures::executor::enter;
3130
///
3231
/// # fn main() {

futures-executor/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures_executor")]
1111

12-
#[cfg(feature = "std")]
13-
#[macro_use]
14-
extern crate futures_util;
15-
1612
macro_rules! if_std {
1713
($($i:item)*) => ($(
1814
#[cfg(feature = "std")]
@@ -21,9 +17,6 @@ macro_rules! if_std {
2117
}
2218

2319
if_std! {
24-
#[macro_use]
25-
extern crate lazy_static;
26-
2720
mod local_pool;
2821
pub use crate::local_pool::{block_on, block_on_stream, BlockingStream, LocalPool, LocalExecutor};
2922

futures-executor/src/local_pool.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::{enter, ThreadPool};
12
use futures_core::future::{Future, FutureObj, LocalFutureObj};
23
use futures_core::stream::{Stream};
34
use futures_core::task::{
@@ -6,6 +7,8 @@ use futures_core::task::{
67
};
78
use futures_util::stream::FuturesUnordered;
89
use futures_util::stream::StreamExt;
10+
use lazy_static::lazy_static;
11+
use pin_utils::pin_mut;
912
use std::cell::{RefCell};
1013
use std::marker::Unpin;
1114
use std::ops::{Deref, DerefMut};
@@ -14,9 +17,6 @@ use std::rc::{Rc, Weak};
1417
use std::sync::Arc;
1518
use std::thread::{self, Thread};
1619

17-
use crate::enter;
18-
use crate::ThreadPool;
19-
2020
/// A single-threaded task pool for polling futures to completion.
2121
///
2222
/// This executor allows you to multiplex any number of tasks onto a single
@@ -101,18 +101,15 @@ impl LocalPool {
101101
/// the `LocalPool` by using its executor handle:
102102
///
103103
/// ```
104-
/// # extern crate futures;
105-
/// # use futures::executor::LocalPool;
104+
/// use futures::executor::LocalPool;
106105
///
107-
/// # fn main() {
108106
/// let mut pool = LocalPool::new();
109107
/// let mut exec = pool.executor();
110108
///
111109
/// // ... spawn some initial tasks using `exec.spawn()` or `exec.spawn_local()`
112110
///
113111
/// // run *all* tasks in the pool to completion, including any newly-spawned ones.
114112
/// pool.run(&mut exec);
115-
/// # }
116113
/// ```
117114
///
118115
/// The function will block the calling thread until *all* tasks in the pool
@@ -129,19 +126,16 @@ impl LocalPool {
129126
///
130127
/// ```
131128
/// # #![feature(pin, arbitrary_self_types, futures_api)]
132-
/// # extern crate futures;
133-
/// # use futures::executor::LocalPool;
134-
/// # use futures::future::ready;
129+
/// use futures::executor::LocalPool;
130+
/// use futures::future::ready;
135131
///
136-
/// # fn main() {
137132
/// let mut pool = LocalPool::new();
138133
/// let mut exec = pool.executor();
139134
/// # let my_app = ready(());
140135
///
141136
/// // run tasks in the pool until `my_app` completes, by default spawning
142137
/// // further tasks back onto the pool
143138
/// pool.run_until(my_app, &mut exec);
144-
/// # }
145139
/// ```
146140
///
147141
/// The function will block the calling thread *only* until the future `f`

futures-executor/tests/local_pool.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
#![allow(unused_imports)]
2-
31
#![feature(pin, arbitrary_self_types, futures_api)]
42

5-
extern crate futures;
6-
extern crate futures_executor;
7-
extern crate futures_channel;
8-
3+
use futures::channel::oneshot;
4+
use futures::executor::LocalPool;
5+
use futures::future::lazy;
6+
use futures::task::{self, Executor};
7+
use futures::prelude::*;
98
use std::boxed::PinBox;
109
use std::cell::{Cell, RefCell};
1110
use std::mem::PinMut;
1211
use std::rc::Rc;
13-
use std::thread;
14-
use std::time::Duration;
15-
16-
use futures::future::lazy;
17-
use futures::prelude::*;
18-
use futures::task::{self, Executor};
19-
use futures_executor::*;
20-
use futures_channel::oneshot;
2112

2213
struct Pending(Rc<()>);
2314

futures-sink/src/lib.rs

-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99

1010
#![feature(pin, arbitrary_self_types, futures_api)]
1111

12-
#[cfg(feature = "std")]
13-
extern crate std;
14-
15-
extern crate futures_core;
16-
#[cfg(feature = "std")]
17-
extern crate futures_channel;
18-
1912
macro_rules! if_std {
2013
($($i:item)*) => ($(
2114
#[cfg(feature = "std")]
@@ -242,8 +235,6 @@ if_std! {
242235
}
243236
}
244237

245-
#[cfg(feature = "either")]
246-
extern crate either;
247238
#[cfg(feature = "either")]
248239
use either::Either;
249240
#[cfg(feature = "either")]

futures-util/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ either = { version = "1.4", default-features = false }
3333
slab = { version = "0.4", optional = true }
3434
futures = { version = "0.1", optional = true }
3535
tokio-executor = { version = "0.1.2", optional = true }
36+
pin-utils = "0.1.0-alpha.1"
3637

3738
[dev-dependencies]
3839
futures-preview = { path = "../futures", version = "0.3.0-alpha.2" }

0 commit comments

Comments
 (0)