feat: Add FlattenCompat struct

yoshuawuyts-patch-1
k-nasa 5 years ago
parent 46f0fb1c64
commit ec98b41c85

@ -47,6 +47,7 @@
#![doc(test(attr(allow(unused_extern_crates, unused_variables))))] #![doc(test(attr(allow(unused_extern_crates, unused_variables))))]
#![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")] #![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")]
#![recursion_limit = "1024"] #![recursion_limit = "1024"]
#![feature(associated_type_bounds)]
use cfg_if::cfg_if; use cfg_if::cfg_if;

@ -0,0 +1,24 @@
use std::pin::Pin;
use crate::stream::{IntoStream, Stream};
use crate::task::{Context, Poll};
/// Real logic of both `Flatten` and `FlatMap` which simply delegate to
/// this type.
#[derive(Clone, Debug)]
struct FlattenCompat<S, U> {
stream: S,
frontiter: Option<U>,
}
impl<S, U> FlattenCompat<S, U> {
pin_utils::unsafe_unpinned!(stream: S);
pin_utils::unsafe_unpinned!(frontiter: Option<U>);
/// Adapts an iterator by flattening it, for use in `flatten()` and `flat_map()`.
pub fn new(stream: S) -> FlattenCompat<S, U> {
FlattenCompat {
stream,
frontiter: None,
}
}
}

@ -106,6 +106,7 @@ cfg_if! {
cfg_if! { cfg_if! {
if #[cfg(any(feature = "unstable", feature = "docs"))] { if #[cfg(any(feature = "unstable", feature = "docs"))] {
mod merge; mod merge;
mod flatten;
use std::pin::Pin; use std::pin::Pin;

Loading…
Cancel
Save