Skip to content

Commit 42a97c0

Browse files
Merge pull request #1185 from MajorBreakfast/pin-utils
pin-utils crate & remove glob imports
2 parents 3fdcfc1 + e68c36a commit 42a97c0

File tree

143 files changed

+269
-571
lines changed

Some content is hidden

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

143 files changed

+269
-571
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

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
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;
9-
use futures::prelude::*;
10-
use futures::channel::mpsc::{
11-
unbounded,
12-
channel,
13-
Sender,
14-
UnboundedSender,
15-
};
16-
6+
use futures::stream::{Stream, StreamExt};
7+
use futures::sink::Sink;
8+
use futures::task::{self, Poll, Wake, LocalWaker};
179
use std::mem::PinMut;
1810
use std::sync::Arc;
1911
use test::Bencher;
@@ -41,7 +33,7 @@ fn noop_cx(f: impl FnOnce(&mut task::Context)) {
4133
fn unbounded_1_tx(b: &mut Bencher) {
4234
noop_cx(|cx| {
4335
b.iter(|| {
44-
let (tx, mut rx) = unbounded();
36+
let (tx, mut rx) = mpsc::unbounded();
4537

4638
// 1000 iterations to avoid measuring overhead of initialization
4739
// Result should be divided by 1000
@@ -64,7 +56,7 @@ fn unbounded_1_tx(b: &mut Bencher) {
6456
fn unbounded_100_tx(b: &mut Bencher) {
6557
noop_cx(|cx| {
6658
b.iter(|| {
67-
let (tx, mut rx) = unbounded();
59+
let (tx, mut rx) = mpsc::unbounded();
6860

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

@@ -86,7 +78,7 @@ fn unbounded_100_tx(b: &mut Bencher) {
8678
fn unbounded_uncontended(b: &mut Bencher) {
8779
noop_cx(|cx| {
8880
b.iter(|| {
89-
let (tx, mut rx) = unbounded();
81+
let (tx, mut rx) = mpsc::unbounded();
9082

9183
for i in 0..1000 {
9284
UnboundedSender::unbounded_send(&tx, i).expect("send");
@@ -127,7 +119,7 @@ impl Stream for TestSender {
127119
fn bounded_1_tx(b: &mut Bencher) {
128120
noop_cx(|cx| {
129121
b.iter(|| {
130-
let (tx, mut rx) = channel(0);
122+
let (tx, mut rx) = mpsc::channel(0);
131123

132124
let mut tx = TestSender { tx, last: 0 };
133125

@@ -146,7 +138,7 @@ fn bounded_100_tx(b: &mut Bencher) {
146138
noop_cx(|cx| {
147139
b.iter(|| {
148140
// Each sender can send one item after specified capacity
149-
let (tx, mut rx) = channel(0);
141+
let (tx, mut rx) = mpsc::channel(0);
150142

151143
let mut tx: Vec<_> = (0..100).map(|_| {
152144
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/src/oneshot.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,22 @@ struct Inner<T> {
8484
///
8585
/// ```
8686
/// use futures::channel::oneshot;
87-
/// use futures::prelude::*;
87+
/// use futures::future::FutureExt;
8888
/// use std::thread;
8989
///
90-
/// fn main() {
91-
/// let (sender, receiver) = oneshot::channel::<i32>();
90+
/// let (sender, receiver) = oneshot::channel::<i32>();
9291
///
9392
/// # let t =
94-
/// thread::spawn(|| {
95-
/// let future = receiver.map(|i| {
96-
/// println!("got: {:?}", i);
97-
/// });
98-
/// // ...
99-
/// # return future;
93+
/// thread::spawn(|| {
94+
/// let future = receiver.map(|i| {
95+
/// println!("got: {:?}", i);
10096
/// });
97+
/// // ...
98+
/// # return future;
99+
/// });
101100
///
102-
/// sender.send(3).unwrap();
101+
/// sender.send(3).unwrap();
103102
/// # futures::executor::block_on(t.join().unwrap());
104-
/// }
105103
/// ```
106104
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
107105
let inner = Arc::new(Inner::new());

futures-channel/tests/channel.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#![feature(async_await, await_macro, futures_api)]
22

3-
extern crate futures;
4-
5-
use std::sync::atomic::*;
6-
use std::thread;
7-
8-
use futures::prelude::*;
9-
use futures::future::poll_fn;
10-
use futures::executor::block_on;
113
use futures::channel::mpsc;
4+
use futures::executor::block_on;
5+
use futures::future::poll_fn;
6+
use futures::stream::StreamExt;
7+
use futures::sink::SinkExt;
8+
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
9+
use std::thread;
1210

1311
#[test]
1412
fn sequence() {

futures-channel/tests/mpsc-close.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
extern crate futures;
2-
3-
use std::thread;
4-
5-
use futures::prelude::*;
6-
use futures::channel::mpsc::*;
1+
use futures::channel::mpsc;
72
use futures::executor::block_on;
3+
use futures::sink::SinkExt;
4+
use futures::stream::StreamExt;
5+
use std::thread;
86

97
#[test]
108
fn smoke() {
11-
let (mut sender, receiver) = channel(1);
9+
let (mut sender, receiver) = mpsc::channel(1);
1210

1311
let t = thread::spawn(move || {
1412
while let Ok(()) = block_on(sender.send(42)) {}

futures-channel/tests/mpsc.rs

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

3-
#[macro_use]
4-
extern crate futures;
5-
6-
use std::thread;
3+
use futures::channel::{mpsc, oneshot};
4+
use futures::executor::{block_on, block_on_stream};
5+
use futures::future::{FutureExt, poll_fn};
6+
use futures::stream::{Stream, StreamExt};
7+
use futures::sink::{Sink, SinkExt};
8+
use futures::task::Poll;
9+
use pin_utils::pin_mut;
710
use std::sync::{Arc, Mutex};
811
use std::sync::atomic::{AtomicUsize, Ordering};
9-
10-
use futures::prelude::*;
11-
use futures::future::poll_fn;
12-
use futures::channel::mpsc;
13-
use futures::channel::oneshot;
14-
use futures::executor::{block_on, block_on_stream};
12+
use std::thread;
1513

1614
trait AssertSend: Send {}
1715
impl AssertSend for mpsc::Sender<i32> {}

futures-channel/tests/oneshot.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
#![feature(futures_api, arbitrary_self_types, pin)]
22

3-
extern crate futures;
4-
3+
use futures::channel::oneshot::{self, Sender};
4+
use futures::executor::block_on;
5+
use futures::future::{Future, FutureExt, poll_fn};
6+
use futures::task::{self, Poll};
57
use std::mem::PinMut;
68
use std::sync::mpsc;
79
use std::thread;
810

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-
1511
#[test]
1612
fn smoke_poll() {
17-
let (mut tx, rx) = channel::<u32>();
13+
let (mut tx, rx) = oneshot::channel::<u32>();
1814
let mut rx = Some(rx);
1915
let f = poll_fn(|cx| {
2016
assert!(tx.poll_cancel(cx).is_pending());
@@ -30,7 +26,7 @@ fn smoke_poll() {
3026

3127
#[test]
3228
fn cancel_notifies() {
33-
let (tx, rx) = channel::<u32>();
29+
let (tx, rx) = oneshot::channel::<u32>();
3430

3531
let t = thread::spawn(|| {
3632
block_on(WaitForCancel { tx: tx });
@@ -62,7 +58,7 @@ fn cancel_lots() {
6258
});
6359

6460
for _ in 0..20000 {
65-
let (otx, orx) = channel::<u32>();
61+
let (otx, orx) = oneshot::channel::<u32>();
6662
let (tx2, rx2) = mpsc::channel();
6763
tx.send((otx, tx2)).unwrap();
6864
drop(orx);
@@ -75,7 +71,7 @@ fn cancel_lots() {
7571

7672
#[test]
7773
fn close() {
78-
let (mut tx, mut rx) = channel::<u32>();
74+
let (mut tx, mut rx) = oneshot::channel::<u32>();
7975
rx.close();
8076
block_on(poll_fn(|cx| {
8177
match rx.poll_unpin(cx) {
@@ -89,7 +85,7 @@ fn close() {
8985

9086
#[test]
9187
fn close_wakes() {
92-
let (tx, mut rx) = channel::<u32>();
88+
let (tx, mut rx) = oneshot::channel::<u32>();
9389
let (tx2, rx2) = mpsc::channel();
9490
let t = thread::spawn(move || {
9591
rx.close();
@@ -102,7 +98,7 @@ fn close_wakes() {
10298

10399
#[test]
104100
fn is_canceled() {
105-
let (tx, rx) = channel::<u32>();
101+
let (tx, rx) = oneshot::channel::<u32>();
106102
assert!(!tx.is_canceled());
107103
drop(rx);
108104
assert!(tx.is_canceled());
@@ -118,7 +114,7 @@ fn cancel_sends() {
118114
});
119115

120116
for _ in 0..20000 {
121-
let (otx, mut orx) = channel::<u32>();
117+
let (otx, mut orx) = oneshot::channel::<u32>();
122118
tx.send(otx).unwrap();
123119

124120
orx.close();

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

+3-7
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::future::{Future, FutureExt};
5+
use futures::task::{self, Poll, Waker, LocalWaker, Wake};
106
use std::marker::Unpin;
117
use std::mem::PinMut;
128
use std::sync::Arc;
@@ -19,7 +15,7 @@ fn notify_noop() -> LocalWaker {
1915
fn wake(_: &Arc<Self>) {}
2016
}
2117

22-
local_waker_from_nonlocal(Arc::new(Noop))
18+
task::local_waker_from_nonlocal(Arc::new(Noop))
2319
}
2420

2521
#[bench]

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::future::Future;
5+
use futures::task::{self, Poll, Waker};
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

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ pub struct EnterError {
2525
/// execute a tasks, and drop the returned [`Enter`](Enter) value after
2626
/// completing task execution:
2727
///
28-
/// ```rust
29-
/// # extern crate futures;
30-
/// # use futures::executor::enter;
28+
/// ```
29+
/// use futures::executor::enter;
3130
///
32-
/// # fn main() {
3331
/// let enter = enter().expect("...");
3432
/// /* run task */
3533
/// drop(enter);
36-
/// # }
3734
/// ```
3835
///
3936
/// Doing so ensures that executors aren't

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

0 commit comments

Comments
 (0)