Skip to content

Fix doc test #729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
//!
//! Call an async function from the main function:
//!
//! ```
#![cfg_attr(feature = "attributes", doc = "```")]
#![cfg_attr(not(feature = "attributes"), doc = "```ignore")]
//! async fn say_hello() {
//! println!("Hello, world!");
//! }
Expand All @@ -151,7 +152,8 @@
//!
//! Await two futures concurrently, and return a tuple of their output:
//!
//! ```
#![cfg_attr(feature = "attributes", doc = "```")]
#![cfg_attr(not(feature = "attributes"), doc = "```ignore")]
//! use async_std::prelude::*;
//!
//! #[async_std::main]
Expand All @@ -164,7 +166,8 @@
//!
//! Create a UDP server that echoes back each received message to the sender:
//!
//! ```no_run
#![cfg_attr(feature = "attributes", doc = "```no_run")]
#![cfg_attr(not(feature = "attributes"), doc = "```ignore")]
//! use async_std::net::UdpSocket;
//!
//! #[async_std::main]
Expand Down
17 changes: 5 additions & 12 deletions src/stream/stream/max.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::cmp::{Ord, Ordering};
use core::marker::PhantomData;
use core::pin::Pin;
use core::future::Future;
use core::pin::Pin;

use pin_project_lite::pin_project;

Expand All @@ -11,29 +10,23 @@ use crate::task::{Context, Poll};
pin_project! {
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct MaxFuture<S, F, T> {
pub struct MaxFuture<S, T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unrelated, why this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is unnecessary type argument.
Certainly that may be different from what I'm doing with this PR.

#[pin]
stream: S,
_compare: PhantomData<F>,
max: Option<T>,
}
}

impl<S, F, T> MaxFuture<S, F, T> {
impl<S, T> MaxFuture<S, T> {
pub(super) fn new(stream: S) -> Self {
Self {
stream,
_compare: PhantomData,
max: None,
}
Self { stream, max: None }
}
}

impl<S, F> Future for MaxFuture<S, F, S::Item>
impl<S> Future for MaxFuture<S, S::Item>
where
S: Stream,
S::Item: Ord,
F: FnMut(&S::Item, &S::Item) -> Ordering,
{
type Output = Option<S::Item>;

Expand Down
17 changes: 5 additions & 12 deletions src/stream/stream/min.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::cmp::{Ord, Ordering};
use core::marker::PhantomData;
use core::pin::Pin;
use core::future::Future;
use core::pin::Pin;

use pin_project_lite::pin_project;

Expand All @@ -11,29 +10,23 @@ use crate::task::{Context, Poll};
pin_project! {
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct MinFuture<S, F, T> {
pub struct MinFuture<S, T> {
#[pin]
stream: S,
_compare: PhantomData<F>,
min: Option<T>,
}
}

impl<S, F, T> MinFuture<S, F, T> {
impl<S, T> MinFuture<S, T> {
pub(super) fn new(stream: S) -> Self {
Self {
stream,
_compare: PhantomData,
min: None,
}
Self { stream, min: None }
}
}

impl<S, F> Future for MinFuture<S, F, S::Item>
impl<S> Future for MinFuture<S, S::Item>
where
S: Stream,
S::Item: Ord,
F: FnMut(&S::Item, &S::Item) -> Ordering,
{
type Output = Option<S::Item>;

Expand Down
16 changes: 8 additions & 8 deletions src/stream/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ extension_trait! {

# Examples

```ignore
```
# fn main() { async_std::task::block_on(async {
#
use async_std::prelude::*;
Expand All @@ -1028,12 +1028,12 @@ extension_trait! {
# }) }
```
"#]
fn max<F>(
fn max(
self,
) -> impl Future<Output = Option<Self::Item>> [MaxFuture<Self, F, Self::Item>]
) -> impl Future<Output = Option<Self::Item>> [MaxFuture<Self, Self::Item>]
where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
Self::Item: Ord,
{
MaxFuture::new(self)
}
Expand All @@ -1044,7 +1044,7 @@ extension_trait! {

# Examples

```ignore
```
# fn main() { async_std::task::block_on(async {
#
use async_std::prelude::*;
Expand All @@ -1061,12 +1061,12 @@ extension_trait! {
# }) }
```
"#]
fn min<F>(
fn min(
self,
) -> impl Future<Output = Option<Self::Item>> [MinFuture<Self, F, Self::Item>]
) -> impl Future<Output = Option<Self::Item>> [MinFuture<Self, Self::Item>]
where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
Self::Item: Ord,
{
MinFuture::new(self)
}
Expand Down