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
}

0 commit comments

Comments
 (0)