Skip to content

Commit 4eb1fbf

Browse files
taiki-ecramertj
authored andcommitted
Support try_collect in no_std environment
1 parent 60ce74d commit 4eb1fbf

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

futures-util/src/try_stream/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pub use self::try_for_each::TryForEach;
3232
mod try_filter_map;
3333
pub use self::try_filter_map::TryFilterMap;
3434

35+
mod try_collect;
36+
pub use self::try_collect::TryCollect;
37+
3538
mod try_concat;
3639
pub use self::try_concat::TryConcat;
3740

@@ -46,11 +49,6 @@ mod try_buffer_unordered;
4649
#[cfg(feature = "std")]
4750
pub use self::try_buffer_unordered::TryBufferUnordered;
4851

49-
#[cfg(feature = "std")]
50-
mod try_collect;
51-
#[cfg(feature = "std")]
52-
pub use self::try_collect::TryCollect;
53-
5452
#[cfg(feature = "std")]
5553
mod try_for_each_concurrent;
5654
#[cfg(feature = "std")]
@@ -334,9 +332,6 @@ pub trait TryStreamExt: TryStream {
334332
///
335333
/// The returned future will be resolved when the stream terminates.
336334
///
337-
/// This method is only available when the `std` feature of this
338-
/// library is activated, and it is activated by default.
339-
///
340335
/// # Examples
341336
///
342337
/// ```
@@ -360,7 +355,6 @@ pub trait TryStreamExt: TryStream {
360355
/// assert_eq!(output, Err(6));
361356
/// # })
362357
/// ```
363-
#[cfg(feature = "std")]
364358
fn try_collect<C: Default + Extend<Self::Ok>>(self) -> TryCollect<Self, C>
365359
where Self: Sized
366360
{

futures-util/src/try_stream/try_collect.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
use core::mem;
2+
use core::pin::Pin;
13
use futures_core::future::{FusedFuture, Future};
24
use futures_core::stream::{FusedStream, TryStream};
35
use futures_core::task::{Waker, Poll};
46
use pin_utils::{unsafe_pinned, unsafe_unpinned};
5-
use std::mem;
6-
use std::pin::Pin;
7-
use std::prelude::v1::*;
87

98
/// A future which attempts to collect all of the values of a stream.
109
///

futures/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,15 @@ pub mod stream {
347347
pub use futures_util::try_stream::{
348348
TryStreamExt,
349349
TryNext, TryForEach, ErrInto,
350-
TryFold, TrySkipWhile,
350+
TryCollect, TryFold, TrySkipWhile,
351351
IntoStream,
352352
// ToDo: AndThen, ErrInto, InspectErr, MapErr, OrElse
353353
};
354354

355355
#[cfg(feature = "std")]
356356
pub use futures_util::try_stream::{
357357
// For TryStreamExt:
358-
TryCollect, TryBufferUnordered,
358+
TryBufferUnordered,
359359
// ToDo: AndThen, InspectErr, MapErr, OrElse
360360
};
361361
}

0 commit comments

Comments
 (0)