Skip to content

Commit 0ce95b5

Browse files
author
Stjepan Glavina
committed
Refactor extension_trait
1 parent 5a184f2 commit 0ce95b5

File tree

14 files changed

+45
-60
lines changed

14 files changed

+45
-60
lines changed

src/fs/dir_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::future::Future;
21
use std::path::Path;
32

43
use cfg_if::cfg_if;
54

5+
use crate::future::Future;
66
use crate::io;
77
use crate::task::blocking;
88

src/fs/open_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::future::Future;
21
use std::path::Path;
32

43
use cfg_if::cfg_if;
54

65
use crate::fs::File;
6+
use crate::future::Future;
77
use crate::io;
88
use crate::task::blocking;
99

src/future/future.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension_trait! {
2929
3030
[`Waker`]: ../task/struct.Waker.html
3131
"#]
32-
pub trait Future [FutureExt: std::future::Future] {
32+
pub trait Future {
3333
#[doc = r#"
3434
The type of value produced on completion.
3535
"#]
@@ -101,4 +101,7 @@ extension_trait! {
101101
"#]
102102
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output>;
103103
}
104+
105+
pub trait FutureExt: std::future::Future {
106+
}
104107
}

src/io/buf_read/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension_trait! {
4141
https://docs.rs/futures-preview/0.3.0-alpha.17/futures/io/trait.AsyncBufRead.html
4242
[provided methods]: #provided-methods
4343
"#]
44-
pub trait BufRead [BufReadExt: futures_io::AsyncBufRead] {
44+
pub trait BufRead {
4545
#[doc = r#"
4646
Returns the contents of the internal buffer, filling it with more data from the
4747
inner reader if it is empty.
@@ -64,7 +64,9 @@ extension_trait! {
6464
should no longer be returned in calls to `read`.
6565
"#]
6666
fn consume(self: Pin<&mut Self>, amt: usize);
67+
}
6768

69+
pub trait BufReadExt: futures_io::AsyncBufRead {
6870
#[doc = r#"
6971
Reads all bytes into `buf` until the delimiter `byte` or EOF is reached.
7072

src/io/read/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension_trait! {
5050
[`poll_read`]: #tymethod.poll_read
5151
[`poll_read_vectored`]: #method.poll_read_vectored
5252
"#]
53-
pub trait Read [ReadExt: futures_io::AsyncRead] {
53+
pub trait Read {
5454
#[doc = r#"
5555
Attempt to read from the `AsyncRead` into `buf`.
5656
"#]
@@ -70,7 +70,9 @@ extension_trait! {
7070
) -> Poll<io::Result<usize>> {
7171
unreachable!("this impl only appears in the rendered docs")
7272
}
73+
}
7374

75+
pub trait ReadExt: futures_io::AsyncRead {
7476
#[doc = r#"
7577
Reads some bytes from the byte stream.
7678

src/io/seek.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extension_trait! {
3333
https://docs.rs/futures-preview/0.3.0-alpha.17/futures/io/trait.AsyncSeek.html
3434
[provided methods]: #provided-methods
3535
"#]
36-
pub trait Seek [SeekExt: futures_io::AsyncSeek] {
36+
pub trait Seek {
3737
#[doc = r#"
3838
Attempt to seek to an offset, in bytes, in a stream.
3939
"#]
@@ -42,7 +42,9 @@ extension_trait! {
4242
cx: &mut Context<'_>,
4343
pos: SeekFrom,
4444
) -> Poll<io::Result<u64>>;
45+
}
4546

47+
pub trait SeekExt: futures_io::AsyncSeek {
4648
#[doc = r#"
4749
Seeks to a new position in a byte stream.
4850
@@ -70,7 +72,7 @@ extension_trait! {
7072
fn seek(
7173
&mut self,
7274
pos: SeekFrom,
73-
) -> impl Future<Output = io::Result<u64>> [SeekFuture<'_, Self>]
75+
) -> impl Future<Output = io::Result<u64>> + '_ [SeekFuture<'_, Self>]
7476
where
7577
Self: Unpin,
7678
{

src/io/write/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension_trait! {
4747
[`poll_flush`]: #tymethod.poll_flush
4848
[`poll_close`]: #tymethod.poll_close
4949
"#]
50-
pub trait Write [WriteExt: futures_io::AsyncWrite] {
50+
pub trait Write {
5151
#[doc = r#"
5252
Attempt to write bytes from `buf` into the object.
5353
"#]
@@ -78,7 +78,9 @@ extension_trait! {
7878
Attempt to close the object.
7979
"#]
8080
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>>;
81+
}
8182

83+
pub trait WriteExt: futures_io::AsyncWrite {
8284
#[doc = r#"
8385
Writes some bytes into the byte stream.
8486

src/stream/stream/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ cfg_if! {
8989
if #[cfg(any(feature = "unstable", feature = "docs"))] {
9090
use std::pin::Pin;
9191

92-
use std::future::Future;
92+
use crate::future::Future;
9393
use crate::stream::FromStream;
9494
}
9595
}
@@ -114,7 +114,7 @@ extension_trait! {
114114
https://docs.rs/futures-preview/0.3.0-alpha.17/futures/stream/trait.Stream.html
115115
[provided methods]: #provided-methods
116116
"#]
117-
pub trait Stream [StreamExt: futures_core::stream::Stream] {
117+
pub trait Stream {
118118
#[doc = r#"
119119
The type of items yielded by this stream.
120120
"#]
@@ -172,7 +172,9 @@ extension_trait! {
172172
```
173173
"#]
174174
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
175+
}
175176

177+
pub trait StreamExt: futures_core::stream::Stream {
176178
#[doc = r#"
177179
Advances the stream and returns the next value.
178180

src/task/blocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! A thread pool for running blocking functions asynchronously.
22
3-
use std::future::Future;
43
use std::sync::atomic::{AtomicU64, Ordering};
54
use std::thread;
65
use std::time::Duration;
76

87
use crossbeam_channel::{bounded, Receiver, Sender};
98
use lazy_static::lazy_static;
109

10+
use crate::future::Future;
1111
use crate::task::task::{JoinHandle, Tag};
1212
use crate::utils::abort_on_panic;
1313

src/task/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub(crate) mod blocking;
8181
#[inline]
8282
pub fn blocking<F, R>(future: F) -> task::JoinHandle<R>
8383
where
84-
F: std::future::Future<Output = R> + Send + 'static,
84+
F: crate::future::Future<Output = R> + Send + 'static,
8585
R: Send + 'static,
8686
{
8787
blocking::spawn(future)

0 commit comments

Comments
 (0)