Skip to content

Commit 70dac51

Browse files
authored
Merge pull request #729 from k-nasa/fix_doc_test
Fix doc test
2 parents 9e6a76a + d30603a commit 70dac51

File tree

4 files changed

+24
-35
lines changed

4 files changed

+24
-35
lines changed

src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@
138138
//!
139139
//! Call an async function from the main function:
140140
//!
141-
//! ```
141+
#![cfg_attr(feature = "attributes", doc = "```")]
142+
#![cfg_attr(not(feature = "attributes"), doc = "```ignore")]
142143
//! async fn say_hello() {
143144
//! println!("Hello, world!");
144145
//! }
@@ -151,7 +152,8 @@
151152
//!
152153
//! Await two futures concurrently, and return a tuple of their output:
153154
//!
154-
//! ```
155+
#![cfg_attr(feature = "attributes", doc = "```")]
156+
#![cfg_attr(not(feature = "attributes"), doc = "```ignore")]
155157
//! use async_std::prelude::*;
156158
//!
157159
//! #[async_std::main]
@@ -164,7 +166,8 @@
164166
//!
165167
//! Create a UDP server that echoes back each received message to the sender:
166168
//!
167-
//! ```no_run
169+
#![cfg_attr(feature = "attributes", doc = "```no_run")]
170+
#![cfg_attr(not(feature = "attributes"), doc = "```ignore")]
168171
//! use async_std::net::UdpSocket;
169172
//!
170173
//! #[async_std::main]

src/stream/stream/max.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use core::cmp::{Ord, Ordering};
2-
use core::marker::PhantomData;
3-
use core::pin::Pin;
42
use core::future::Future;
3+
use core::pin::Pin;
54

65
use pin_project_lite::pin_project;
76

@@ -11,29 +10,23 @@ use crate::task::{Context, Poll};
1110
pin_project! {
1211
#[doc(hidden)]
1312
#[allow(missing_debug_implementations)]
14-
pub struct MaxFuture<S, F, T> {
13+
pub struct MaxFuture<S, T> {
1514
#[pin]
1615
stream: S,
17-
_compare: PhantomData<F>,
1816
max: Option<T>,
1917
}
2018
}
2119

22-
impl<S, F, T> MaxFuture<S, F, T> {
20+
impl<S, T> MaxFuture<S, T> {
2321
pub(super) fn new(stream: S) -> Self {
24-
Self {
25-
stream,
26-
_compare: PhantomData,
27-
max: None,
28-
}
22+
Self { stream, max: None }
2923
}
3024
}
3125

32-
impl<S, F> Future for MaxFuture<S, F, S::Item>
26+
impl<S> Future for MaxFuture<S, S::Item>
3327
where
3428
S: Stream,
3529
S::Item: Ord,
36-
F: FnMut(&S::Item, &S::Item) -> Ordering,
3730
{
3831
type Output = Option<S::Item>;
3932

src/stream/stream/min.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use core::cmp::{Ord, Ordering};
2-
use core::marker::PhantomData;
3-
use core::pin::Pin;
42
use core::future::Future;
3+
use core::pin::Pin;
54

65
use pin_project_lite::pin_project;
76

@@ -11,29 +10,23 @@ use crate::task::{Context, Poll};
1110
pin_project! {
1211
#[doc(hidden)]
1312
#[allow(missing_debug_implementations)]
14-
pub struct MinFuture<S, F, T> {
13+
pub struct MinFuture<S, T> {
1514
#[pin]
1615
stream: S,
17-
_compare: PhantomData<F>,
1816
min: Option<T>,
1917
}
2018
}
2119

22-
impl<S, F, T> MinFuture<S, F, T> {
20+
impl<S, T> MinFuture<S, T> {
2321
pub(super) fn new(stream: S) -> Self {
24-
Self {
25-
stream,
26-
_compare: PhantomData,
27-
min: None,
28-
}
22+
Self { stream, min: None }
2923
}
3024
}
3125

32-
impl<S, F> Future for MinFuture<S, F, S::Item>
26+
impl<S> Future for MinFuture<S, S::Item>
3327
where
3428
S: Stream,
3529
S::Item: Ord,
36-
F: FnMut(&S::Item, &S::Item) -> Ordering,
3730
{
3831
type Output = Option<S::Item>;
3932

src/stream/stream/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ extension_trait! {
10111011
10121012
# Examples
10131013
1014-
```ignore
1014+
```
10151015
# fn main() { async_std::task::block_on(async {
10161016
#
10171017
use async_std::prelude::*;
@@ -1028,12 +1028,12 @@ extension_trait! {
10281028
# }) }
10291029
```
10301030
"#]
1031-
fn max<F>(
1031+
fn max(
10321032
self,
1033-
) -> impl Future<Output = Option<Self::Item>> [MaxFuture<Self, F, Self::Item>]
1033+
) -> impl Future<Output = Option<Self::Item>> [MaxFuture<Self, Self::Item>]
10341034
where
10351035
Self: Sized,
1036-
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1036+
Self::Item: Ord,
10371037
{
10381038
MaxFuture::new(self)
10391039
}
@@ -1044,7 +1044,7 @@ extension_trait! {
10441044
10451045
# Examples
10461046
1047-
```ignore
1047+
```
10481048
# fn main() { async_std::task::block_on(async {
10491049
#
10501050
use async_std::prelude::*;
@@ -1061,12 +1061,12 @@ extension_trait! {
10611061
# }) }
10621062
```
10631063
"#]
1064-
fn min<F>(
1064+
fn min(
10651065
self,
1066-
) -> impl Future<Output = Option<Self::Item>> [MinFuture<Self, F, Self::Item>]
1066+
) -> impl Future<Output = Option<Self::Item>> [MinFuture<Self, Self::Item>]
10671067
where
10681068
Self: Sized,
1069-
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1069+
Self::Item: Ord,
10701070
{
10711071
MinFuture::new(self)
10721072
}

0 commit comments

Comments
 (0)