Skip to content

Commit 548733e

Browse files
author
Stjepan Glavina
authored
Cleanup stream traits (#487)
* Cleanup stream traits * Fix docs
1 parent 4a78f73 commit 548733e

Some content is hidden

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

89 files changed

+229
-249
lines changed

src/collections/binary_heap/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use std::collections::BinaryHeap;
22
use std::pin::Pin;
33

4+
use crate::prelude::*;
45
use crate::stream::{self, FromStream, IntoStream};
56

67
impl<T: Ord> FromStream<T> for BinaryHeap<T> {
78
#[inline]
8-
fn from_stream<'a, S: IntoStream<Item = T>>(
9+
fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
910
stream: S,
10-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
11-
where
12-
<S as IntoStream>::IntoStream: 'a,
13-
{
11+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1412
let stream = stream.into_stream();
1513

1614
Box::pin(async move {

src/collections/btree_map/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use std::collections::BTreeMap;
22
use std::pin::Pin;
33

4+
use crate::prelude::*;
45
use crate::stream::{self, FromStream, IntoStream};
56

67
impl<K: Ord, V> FromStream<(K, V)> for BTreeMap<K, V> {
78
#[inline]
8-
fn from_stream<'a, S: IntoStream<Item = (K, V)>>(
9+
fn from_stream<'a, S: IntoStream<Item = (K, V)> + 'a>(
910
stream: S,
10-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
11-
where
12-
<S as IntoStream>::IntoStream: 'a,
13-
{
11+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1412
let stream = stream.into_stream();
1513

1614
Box::pin(async move {

src/collections/btree_set/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use std::collections::BTreeSet;
22
use std::pin::Pin;
33

4+
use crate::prelude::*;
45
use crate::stream::{self, FromStream, IntoStream};
56

67
impl<T: Ord> FromStream<T> for BTreeSet<T> {
78
#[inline]
8-
fn from_stream<'a, S: IntoStream<Item = T>>(
9+
fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
910
stream: S,
10-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
11-
where
12-
<S as IntoStream>::IntoStream: 'a,
13-
{
11+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1412
let stream = stream.into_stream();
1513

1614
Box::pin(async move {

src/collections/hash_map/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashMap;
22
use std::hash::{BuildHasher, Hash};
33
use std::pin::Pin;
44

5+
use crate::prelude::*;
56
use crate::stream::{self, FromStream, IntoStream};
67

78
impl<K, V, H> FromStream<(K, V)> for HashMap<K, V, H>
@@ -10,12 +11,9 @@ where
1011
H: BuildHasher + Default,
1112
{
1213
#[inline]
13-
fn from_stream<'a, S: IntoStream<Item = (K, V)>>(
14+
fn from_stream<'a, S: IntoStream<Item = (K, V)> + 'a>(
1415
stream: S,
15-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
16-
where
17-
<S as IntoStream>::IntoStream: 'a,
18-
{
16+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1917
let stream = stream.into_stream();
2018

2119
Box::pin(async move {

src/collections/hash_set/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashSet;
22
use std::hash::{BuildHasher, Hash};
33
use std::pin::Pin;
44

5+
use crate::prelude::*;
56
use crate::stream::{self, FromStream, IntoStream};
67

78
impl<T, H> FromStream<T> for HashSet<T, H>
@@ -10,12 +11,9 @@ where
1011
H: BuildHasher + Default,
1112
{
1213
#[inline]
13-
fn from_stream<'a, S: IntoStream<Item = T>>(
14+
fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
1415
stream: S,
15-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
16-
where
17-
<S as IntoStream>::IntoStream: 'a,
18-
{
16+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1917
let stream = stream.into_stream();
2018

2119
Box::pin(async move {

src/collections/linked_list/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use std::collections::LinkedList;
22
use std::pin::Pin;
33

4+
use crate::prelude::*;
45
use crate::stream::{self, FromStream, IntoStream};
56

67
impl<T> FromStream<T> for LinkedList<T> {
78
#[inline]
8-
fn from_stream<'a, S: IntoStream<Item = T>>(
9+
fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
910
stream: S,
10-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
11-
where
12-
<S as IntoStream>::IntoStream: 'a,
13-
{
11+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1412
let stream = stream.into_stream();
1513

1614
Box::pin(async move {

src/collections/vec_deque/from_stream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use std::collections::VecDeque;
22
use std::pin::Pin;
33

4+
use crate::prelude::*;
45
use crate::stream::{self, FromStream, IntoStream};
56

67
impl<T> FromStream<T> for VecDeque<T> {
78
#[inline]
8-
fn from_stream<'a, S: IntoStream<Item = T>>(
9+
fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
910
stream: S,
10-
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>
11-
where
12-
<S as IntoStream>::IntoStream: 'a,
13-
{
11+
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
1412
let stream = stream.into_stream();
1513

1614
Box::pin(async move {

src/fs/file_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cfg_docs! {
4040
/// # Ok(()) }) }
4141
/// ```
4242
pub fn is_dir(&self) -> bool {
43-
unimplemented!()
43+
unreachable!("this impl only appears in the rendered docs")
4444
}
4545

4646
/// Returns `true` if this file type represents a regular file.
@@ -60,7 +60,7 @@ cfg_docs! {
6060
/// # Ok(()) }) }
6161
/// ```
6262
pub fn is_file(&self) -> bool {
63-
unimplemented!()
63+
unreachable!("this impl only appears in the rendered docs")
6464
}
6565

6666
/// Returns `true` if this file type represents a symbolic link.
@@ -78,7 +78,7 @@ cfg_docs! {
7878
/// # Ok(()) }) }
7979
/// ```
8080
pub fn is_symlink(&self) -> bool {
81-
unimplemented!()
81+
unreachable!("this impl only appears in the rendered docs")
8282
}
8383
}
8484
}

src/fs/metadata.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ cfg_docs! {
7878
/// # Ok(()) }) }
7979
/// ```
8080
pub fn file_type(&self) -> FileType {
81-
unimplemented!()
81+
unreachable!("this impl only appears in the rendered docs")
8282
}
8383

8484
/// Returns `true` if this metadata is for a regular directory.
@@ -98,7 +98,7 @@ cfg_docs! {
9898
/// # Ok(()) }) }
9999
/// ```
100100
pub fn is_dir(&self) -> bool {
101-
unimplemented!()
101+
unreachable!("this impl only appears in the rendered docs")
102102
}
103103

104104
/// Returns `true` if this metadata is for a regular file.
@@ -118,7 +118,7 @@ cfg_docs! {
118118
/// # Ok(()) }) }
119119
/// ```
120120
pub fn is_file(&self) -> bool {
121-
unimplemented!()
121+
unreachable!("this impl only appears in the rendered docs")
122122
}
123123

124124
/// Returns the file size in bytes.
@@ -136,7 +136,7 @@ cfg_docs! {
136136
/// # Ok(()) }) }
137137
/// ```
138138
pub fn len(&self) -> u64 {
139-
unimplemented!()
139+
unreachable!("this impl only appears in the rendered docs")
140140
}
141141

142142
/// Returns the permissions from this metadata.
@@ -154,7 +154,7 @@ cfg_docs! {
154154
/// # Ok(()) }) }
155155
/// ```
156156
pub fn permissions(&self) -> Permissions {
157-
unimplemented!()
157+
unreachable!("this impl only appears in the rendered docs")
158158
}
159159

160160
/// Returns the last modification time.
@@ -177,7 +177,7 @@ cfg_docs! {
177177
/// # Ok(()) }) }
178178
/// ```
179179
pub fn modified(&self) -> io::Result<SystemTime> {
180-
unimplemented!()
180+
unreachable!("this impl only appears in the rendered docs")
181181
}
182182

183183
/// Returns the last access time.
@@ -200,7 +200,7 @@ cfg_docs! {
200200
/// # Ok(()) }) }
201201
/// ```
202202
pub fn accessed(&self) -> io::Result<SystemTime> {
203-
unimplemented!()
203+
unreachable!("this impl only appears in the rendered docs")
204204
}
205205

206206
/// Returns the creation time.
@@ -223,7 +223,7 @@ cfg_docs! {
223223
/// # Ok(()) }) }
224224
/// ```
225225
pub fn created(&self) -> io::Result<SystemTime> {
226-
unimplemented!()
226+
unreachable!("this impl only appears in the rendered docs")
227227
}
228228
}
229229
}

src/fs/permissions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cfg_docs! {
2929
/// # Ok(()) }) }
3030
/// ```
3131
pub fn readonly(&self) -> bool {
32-
unimplemented!()
32+
unreachable!("this impl only appears in the rendered docs")
3333
}
3434

3535
/// Configures the read-only flag.
@@ -50,7 +50,7 @@ cfg_docs! {
5050
/// # Ok(()) }) }
5151
/// ```
5252
pub fn set_readonly(&mut self, readonly: bool) {
53-
unimplemented!()
53+
unreachable!("this impl only appears in the rendered docs")
5454
}
5555
}
5656
}

src/fs/read_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::pin::Pin;
2+
use std::future::Future;
23

34
use crate::fs::DirEntry;
4-
use crate::future::Future;
55
use crate::io;
66
use crate::path::Path;
77
use crate::stream::Stream;

src/future/future/delay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::pin::Pin;
22
use std::time::Duration;
3+
use std::future::Future;
34

45
use futures_timer::Delay;
56
use pin_project_lite::pin_project;
67

7-
use crate::future::Future;
88
use crate::task::{Context, Poll};
99

1010
pin_project! {

src/future/future/flatten.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use futures_core::ready;
21
use std::pin::Pin;
2+
use std::future::Future;
33

4-
use crate::future::Future;
5-
use crate::future::IntoFuture;
6-
use crate::task::{Context, Poll};
4+
use crate::future::{IntoFuture};
5+
use crate::task::{ready, Context, Poll};
76

87
#[derive(Debug)]
98
pub struct FlattenFuture<Fut1, Fut2> {

src/future/into_future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::future::Future;
1+
use std::future::Future;
22

33
/// Convert a type into a `Future`.
44
///

src/future/pending.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::marker::PhantomData;
22
use std::pin::Pin;
3+
use std::future::Future;
34

4-
use crate::future::Future;
55
use crate::task::{Context, Poll};
66

77
/// Never resolves to a value.

src/future/poll_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::pin::Pin;
2+
use std::future::Future;
23

3-
use crate::future::Future;
44
use crate::task::{Context, Poll};
55

66
/// Creates a new future wrapping around a function returning [`Poll`].

src/future/timeout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::error::Error;
22
use std::fmt;
33
use std::pin::Pin;
44
use std::time::Duration;
5+
use std::future::Future;
56

67
use futures_timer::Delay;
78
use pin_project_lite::pin_project;
89

9-
use crate::future::Future;
1010
use crate::task::{Context, Poll};
1111

1212
/// Awaits a future or times out after a duration of time.

src/io/buf_read/read_line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::mem;
22
use std::pin::Pin;
33
use std::str;
4+
use std::future::Future;
45

56
use super::read_until_internal;
6-
use crate::future::Future;
77
use crate::io::{self, BufRead};
88
use crate::task::{Context, Poll};
99

src/io/buf_read/read_until.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::pin::Pin;
2+
use std::future::Future;
23

34
use super::read_until_internal;
4-
use crate::future::Future;
55
use crate::io::{self, BufRead};
66
use crate::task::{Context, Poll};
77

src/io/buf_writer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::fmt;
22
use std::pin::Pin;
33

4-
use futures_core::ready;
54
use pin_project_lite::pin_project;
65

76
use crate::io::write::WriteExt;
87
use crate::io::{self, Seek, SeekFrom, Write};
9-
use crate::task::{Context, Poll};
8+
use crate::task::{Context, Poll, ready};
109

1110
const DEFAULT_CAPACITY: usize = 8 * 1024;
1211

src/io/copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::pin::Pin;
2+
use std::future::Future;
23

34
use pin_project_lite::pin_project;
45

5-
use crate::future::Future;
66
use crate::io::{self, BufRead, BufReader, Read, Write};
77
use crate::task::{Context, Poll};
88

src/io/read/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::pin::Pin;
2+
use std::future::Future;
23

3-
use crate::future::Future;
44
use crate::io::{self, Read};
55
use crate::task::{Context, Poll};
66

src/io/read/read_exact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::mem;
22
use std::pin::Pin;
3+
use std::future::Future;
34

4-
use crate::future::Future;
55
use crate::io::{self, Read};
66
use crate::task::{Context, Poll};
77

0 commit comments

Comments
 (0)