mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-12 05:07:16 +01:00
722 lines
130 KiB
HTML
722 lines
130 KiB
HTML
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="An extension trait for `Stream`s that provides a variety of convenient combinator functions."><title>StreamExt in futures_util::stream - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-b0742ba02757f159.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="futures_util" data-themes="" data-resource-suffix="" data-rustdoc-version="1.83.0 (90b35a623 2024-11-26)" data-channel="1.83.0" data-search-js="search-f0d225181b97f9a4.js" data-settings-js="settings-805db61a62df4bd2.js" ><script src="../../static.files/storage-1d39b6787ed640ff.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-f070b9041d14864c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-0111fcff984fae8f.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../futures_util/index.html">futures_<wbr>util</a><span class="version">0.3.31</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Stream<wbr>Ext</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.all" title="all">all</a></li><li><a href="#method.any" title="any">any</a></li><li><a href="#method.by_ref" title="by_ref">by_ref</a></li><li><a href="#method.chain" title="chain">chain</a></li><li><a href="#method.collect" title="collect">collect</a></li><li><a href="#method.concat" title="concat">concat</a></li><li><a href="#method.count" title="count">count</a></li><li><a href="#method.cycle" title="cycle">cycle</a></li><li><a href="#method.enumerate" title="enumerate">enumerate</a></li><li><a href="#method.filter" title="filter">filter</a></li><li><a href="#method.filter_map" title="filter_map">filter_map</a></li><li><a href="#method.flat_map" title="flat_map">flat_map</a></li><li><a href="#method.flatten" title="flatten">flatten</a></li><li><a href="#method.fold" title="fold">fold</a></li><li><a href="#method.for_each" title="for_each">for_each</a></li><li><a href="#method.fuse" title="fuse">fuse</a></li><li><a href="#method.inspect" title="inspect">inspect</a></li><li><a href="#method.into_future" title="into_future">into_future</a></li><li><a href="#method.left_stream" title="left_stream">left_stream</a></li><li><a href="#method.map" title="map">map</a></li><li><a href="#method.next" title="next">next</a></li><li><a href="#method.peekable" title="peekable">peekable</a></li><li><a href="#method.poll_next_unpin" title="poll_next_unpin">poll_next_unpin</a></li><li><a href="#method.right_stream" title="right_stream">right_stream</a></li><li><a href="#method.scan" title="scan">scan</a></li><li><a href="#method.select_next_some" title="select_next_some">select_next_some</a></li><li><a href="#method.skip" title="skip">skip</a></li><li><a href="#method.sk
|
|||
|
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 34 methods</span></summary> // Provided methods
|
|||
|
fn <a href="#method.next" class="fn">next</a>(&mut self) -> <a class="struct" href="struct.Next.html" title="struct futures_util::stream::Next">Next</a><'_, Self> <a href="#" class="tooltip" data-notable-ty="Next<'_, Self>">ⓘ</a>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.into_future" class="fn">into_future</a>(self) -> <a class="struct" href="struct.StreamFuture.html" title="struct futures_util::stream::StreamFuture">StreamFuture</a><Self> <a href="#" class="tooltip" data-notable-ty="StreamFuture<Self>">ⓘ</a>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.map" class="fn">map</a><T, F>(self, f: F) -> <a class="struct" href="struct.Map.html" title="struct futures_util::stream::Map">Map</a><Self, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> T,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.enumerate" class="fn">enumerate</a>(self) -> <a class="struct" href="struct.Enumerate.html" title="struct futures_util::stream::Enumerate">Enumerate</a><Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.filter" class="fn">filter</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.Filter.html" title="struct futures_util::stream::Filter">Filter</a><Self, Fut, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.filter_map" class="fn">filter_map</a><Fut, T, F>(self, f: F) -> <a class="struct" href="struct.FilterMap.html" title="struct futures_util::stream::FilterMap">FilterMap</a><Self, Fut, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.then" class="fn">then</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.Then.html" title="struct futures_util::stream::Then">Then</a><Self, Fut, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.collect" class="fn">collect</a><C: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>>(self) -> <a class="struct" href="struct.Collect.html" title="struct futures_util::stream::Collect">Collect</a><Self, C> <a href="#" class="tooltip" data-notable-ty="Collect<Self, C>">ⓘ</a>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.unzip" class="fn">unzip</a><A, B, FromA, FromB>(self) -> <a class="struct" href="struct.Unzip.html" title="struct futures_util::stream::Unzip">Unzip</a><Self, FromA, FromB> <a href="#" class="tooltip" data-notable-ty="Unzip<Self, FromA, FromB>">ⓘ</a>
|
|||
|
<span class="where">where FromA: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><A>,
|
|||
|
FromB: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><B>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.tuple.html">(A, B)</a>></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.concat" class="fn">concat</a>(self) -> <a class="struct" href="struct.Concat.html" title="struct futures_util::stream::Concat">Concat</a><Self> <a href="#" class="tooltip" data-notable-ty="Concat<Self>">ⓘ</a>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><<<Self as <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>>::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::collect::IntoIterator::Item">Item</a>> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.count" class="fn">count</a>(self) -> <a class="struct" href="struct.Count.html" title="struct futures_util::stream::Count">Count</a><Self> <a href="#" class="tooltip" data-notable-ty="Count<Self>">ⓘ</a>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.cycle" class="fn">cycle</a>(self) -> <a class="struct" href="struct.Cycle.html" title="struct futures_util::stream::Cycle">Cycle</a><Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.fold" class="fn">fold</a><T, Fut, F>(self, init: T, f: F) -> <a class="struct" href="struct.Fold.html" title="struct futures_util::stream::Fold">Fold</a><Self, Fut, T, F> <a href="#" class="tooltip" data-notable-ty="Fold<Self, Fut, T, F>">ⓘ</a>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(T, Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = T>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.any" class="fn">any</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.Any.html" title="struct futures_util::stream::Any">Any</a><Self, Fut, F> <a href="#" class="tooltip" data-notable-ty="Any<Self, Fut, F>">ⓘ</a>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.all" class="fn">all</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.All.html" title="struct futures_util::stream::All">All</a><Self, Fut, F> <a href="#" class="tooltip" data-notable-ty="All<Self, Fut, F>">ⓘ</a>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.flatten" class="fn">flatten</a>(self) -> <a class="struct" href="struct.Flatten.html" title="struct futures_util::stream::Flatten">Flatten</a><Self>
|
|||
|
<span class="where">where Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.flat_map" class="fn">flat_map</a><U, F>(self, f: F) -> <a class="struct" href="struct.FlatMap.html" title="struct futures_util::stream::FlatMap">FlatMap</a><Self, U, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> U,
|
|||
|
U: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.scan" class="fn">scan</a><S, B, Fut, F>(self, initial_state: S, f: F) -> <a class="struct" href="struct.Scan.html" title="struct futures_util::stream::Scan">Scan</a><Self, S, Fut, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.reference.html">&mut S</a>, Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><B>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.skip_while" class="fn">skip_while</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.SkipWhile.html" title="struct futures_util::stream::SkipWhile">SkipWhile</a><Self, Fut, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.take_while" class="fn">take_while</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.TakeWhile.html" title="struct futures_util::stream::TakeWhile">TakeWhile</a><Self, Fut, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.take_until" class="fn">take_until</a><Fut>(self, fut: Fut) -> <a class="struct" href="struct.TakeUntil.html" title="struct futures_util::stream::TakeUntil">TakeUntil</a><Self, Fut>
|
|||
|
<span class="where">where Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.for_each" class="fn">for_each</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.ForEach.html" title="struct futures_util::stream::ForEach">ForEach</a><Self, Fut, F> <a href="#" class="tooltip" data-notable-ty="ForEach<Self, Fut, F>">ⓘ</a>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.unit.html">()</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.take" class="fn">take</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Take.html" title="struct futures_util::stream::Take">Take</a><Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.skip" class="fn">skip</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Skip.html" title="struct futures_util::stream::Skip">Skip</a><Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.fuse" class="fn">fuse</a>(self) -> <a class="struct" href="struct.Fuse.html" title="struct futures_util::stream::Fuse">Fuse</a><Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.by_ref" class="fn">by_ref</a>(&mut self) -> &mut Self { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.zip" class="fn">zip</a><St>(self, other: St) -> <a class="struct" href="struct.Zip.html" title="struct futures_util::stream::Zip">Zip</a><Self, St>
|
|||
|
<span class="where">where St: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.chain" class="fn">chain</a><St>(self, other: St) -> <a class="struct" href="struct.Chain.html" title="struct futures_util::stream::Chain">Chain</a><Self, St>
|
|||
|
<span class="where">where St: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.peekable" class="fn">peekable</a>(self) -> <a class="struct" href="struct.Peekable.html" title="struct futures_util::stream::Peekable">Peekable</a><Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.inspect" class="fn">inspect</a><F>(self, f: F) -> <a class="struct" href="struct.Inspect.html" title="struct futures_util::stream::Inspect">Inspect</a><Self, F>
|
|||
|
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>),
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.left_stream" class="fn">left_stream</a><B>(self) -> <a class="enum" href="../future/enum.Either.html" title="enum futures_util::future::Either">Either</a><Self, B> <a href="#" class="tooltip" data-notable-ty="Either<Self, B>">ⓘ</a>
|
|||
|
<span class="where">where B: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.right_stream" class="fn">right_stream</a><B>(self) -> <a class="enum" href="../future/enum.Either.html" title="enum futures_util::future::Either">Either</a><B, Self> <a href="#" class="tooltip" data-notable-ty="Either<B, Self>">ⓘ</a>
|
|||
|
<span class="where">where B: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.poll_next_unpin" class="fn">poll_next_unpin</a>(
|
|||
|
&mut self,
|
|||
|
cx: &mut <a class="struct" href="https://doc.rust-lang.org/1.83.0/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>,
|
|||
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.select_next_some" class="fn">select_next_some</a>(&mut self) -> <a class="struct" href="struct.SelectNextSome.html" title="struct futures_util::stream::SelectNextSome">SelectNextSome</a><'_, Self> <a href="#" class="tooltip" data-notable-ty="SelectNextSome<'_, Self>">ⓘ</a>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="trait.FusedStream.html" title="trait futures_util::stream::FusedStream">FusedStream</a></span> { ... }
|
|||
|
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An extension trait for <code>Stream</code>s that provides a variety of convenient
|
|||
|
combinator functions.</p>
|
|||
|
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.next" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#273-278">source</a><h4 class="code-header">fn <a href="#method.next" class="fn">next</a>(&mut self) -> <a class="struct" href="struct.Next.html" title="struct futures_util::stream::Next">Next</a><'_, Self> <a href="#" class="tooltip" data-notable-ty="Next<'_, Self>">ⓘ</a><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class="docblock"><p>Creates a future that resolves to the next item in the stream.</p>
|
|||
|
<p>Note that because <code>next</code> doesn’t take ownership over the stream,
|
|||
|
the <a href="trait.Stream.html" title="trait futures_util::stream::Stream"><code>Stream</code></a> type must be <a href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin"><code>Unpin</code></a>. If you want to use <code>next</code> with a
|
|||
|
<a href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin"><code>!Unpin</code></a> stream, you’ll first have to pin the stream. This can
|
|||
|
be done by boxing the stream using [<code>Box::pin</code>] or
|
|||
|
pinning it to the stack using the <code>pin_mut!</code> macro from the <code>pin_utils</code>
|
|||
|
crate.</p>
|
|||
|
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">3</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="number">1</span>));
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="number">2</span>));
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="number">3</span>));
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">None</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_future" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#308-313">source</a><h4 class="code-header">fn <a href="#method.into_future" class="fn">into_future</a>(self) -> <a class="struct" href="struct.StreamFuture.html" title="struct futures_util::stream::StreamFuture">StreamFuture</a><Self> <a href="#" class="tooltip" data-notable-ty="StreamFuture<Self>">ⓘ</a><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class="docblock"><p>Converts this stream into a future of <code>(next_item, tail_of_stream)</code>.
|
|||
|
If the stream terminates, then the next item is <a href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>.</p>
|
|||
|
<p>The returned future can be used to compose streams and futures together
|
|||
|
by placing everything into the “world of futures”.</p>
|
|||
|
<p>Note that because <code>into_future</code> moves the stream, the <a href="trait.Stream.html" title="trait futures_util::stream::Stream"><code>Stream</code></a> type
|
|||
|
must be <a href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin"><code>Unpin</code></a>. If you want to use <code>into_future</code> with a
|
|||
|
<a href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin"><code>!Unpin</code></a> stream, you’ll first have to pin the stream. This can
|
|||
|
be done by boxing the stream using [<code>Box::pin</code>] or
|
|||
|
pinning it to the stack using the <code>pin_mut!</code> macro from the <code>pin_utils</code>
|
|||
|
crate.</p>
|
|||
|
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">3</span>);
|
|||
|
|
|||
|
<span class="kw">let </span>(item, stream) = stream.into_future().<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>), item);
|
|||
|
|
|||
|
<span class="kw">let </span>(item, stream) = stream.into_future().<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">2</span>), item);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.map" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#341-347">source</a><h4 class="code-header">fn <a href="#method.map" class="fn">map</a><T, F>(self, f: F) -> <a class="struct" href="struct.Map.html" title="struct futures_util::stream::Map">Map</a><Self, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> T,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Maps this stream’s items to a different type, returning a new stream of
|
|||
|
the resulting type.</p>
|
|||
|
<p>The provided closure is executed over all elements of this stream as
|
|||
|
they are made available. It is executed inline with calls to
|
|||
|
<a href="trait.Stream.html#tymethod.poll_next" title="method futures_util::stream::Stream::poll_next"><code>poll_next</code></a>.</p>
|
|||
|
<p>Note that this function consumes the stream passed into it and returns a
|
|||
|
wrapped version of it, similar to the existing <code>map</code> methods in the
|
|||
|
standard library.</p>
|
|||
|
<p>See <a href="trait.StreamExt.html#method.then"><code>StreamExt::then</code></a> if you want to use a closure that
|
|||
|
returns a future instead of a value.</p>
|
|||
|
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">3</span>);
|
|||
|
<span class="kw">let </span>stream = stream.map(|x| x + <span class="number">3</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.enumerate" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#387-392">source</a><h4 class="code-header">fn <a href="#method.enumerate" class="fn">enumerate</a>(self) -> <a class="struct" href="struct.Enumerate.html" title="struct futures_util::stream::Enumerate">Enumerate</a><Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Creates a stream which gives the current iteration count as well as
|
|||
|
the next value.</p>
|
|||
|
<p>The stream returned yields pairs <code>(i, val)</code>, where <code>i</code> is the
|
|||
|
current index of iteration and <code>val</code> is the value returned by the
|
|||
|
stream.</p>
|
|||
|
<p><code>enumerate()</code> keeps its count as a <a href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html" title="primitive usize"><code>usize</code></a>. If you want to count by a
|
|||
|
different sized integer, the <a href="trait.StreamExt.html#method.zip" title="method futures_util::stream::StreamExt::zip"><code>zip</code></a> function provides similar
|
|||
|
functionality.</p>
|
|||
|
<h5 id="overflow-behavior"><a class="doc-anchor" href="#overflow-behavior">§</a>Overflow Behavior</h5>
|
|||
|
<p>The method does no guarding against overflows, so enumerating more than
|
|||
|
<a href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html#associatedconstant.MAX" title="associated constant usize::MAX"><code>usize::MAX</code></a> elements either produces the wrong result or panics. If
|
|||
|
debug assertions are enabled, a panic is guaranteed.</p>
|
|||
|
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
|||
|
<p>The returned stream might panic if the to-be-returned index would
|
|||
|
overflow a <a href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html" title="primitive usize"><code>usize</code></a>.</p>
|
|||
|
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="macro">vec!</span>[<span class="string">'a'</span>, <span class="string">'b'</span>, <span class="string">'c'</span>]);
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>stream = stream.enumerate();
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>((<span class="number">0</span>, <span class="string">'a'</span>)));
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="string">'b'</span>)));
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>((<span class="number">2</span>, <span class="string">'c'</span>)));
|
|||
|
<span class="macro">assert_eq!</span>(stream.next().<span class="kw">await</span>, <span class="prelude-val">None</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.filter" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#420-427">source</a><h4 class="code-header">fn <a href="#method.filter" class="fn">filter</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.Filter.html" title="struct futures_util::stream::Filter">Filter</a><Self, Fut, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Filters the values produced by this stream according to the provided
|
|||
|
asynchronous predicate.</p>
|
|||
|
<p>As values of this stream are made available, the provided predicate <code>f</code>
|
|||
|
will be run against them. If the predicate returns a <code>Future</code> which
|
|||
|
resolves to <code>true</code>, then the stream will yield the value, but if the
|
|||
|
predicate returns a <code>Future</code> which resolves to <code>false</code>, then the value
|
|||
|
will be discarded and the next value will be produced.</p>
|
|||
|
<p>Note that this function consumes the stream passed into it and returns a
|
|||
|
wrapped version of it, similar to the existing <code>filter</code> methods in the
|
|||
|
standard library.</p>
|
|||
|
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
<span class="kw">let </span>events = stream.filter(|x| future::ready(x % <span class="number">2 </span>== <span class="number">0</span>));
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">8</span>, <span class="number">10</span>], events.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.filter_map" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#454-461">source</a><h4 class="code-header">fn <a href="#method.filter_map" class="fn">filter_map</a><Fut, T, F>(self, f: F) -> <a class="struct" href="struct.FilterMap.html" title="struct futures_util::stream::FilterMap">FilterMap</a><Self, Fut, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Filters the values produced by this stream while simultaneously mapping
|
|||
|
them to a different type according to the provided asynchronous closure.</p>
|
|||
|
<p>As values of this stream are made available, the provided function will
|
|||
|
be run on them. If the future returned by the predicate <code>f</code> resolves to
|
|||
|
<a href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html#variant.Some" title="variant core::option::Option::Some"><code>Some(item)</code></a> then the stream will yield the value <code>item</code>, but if
|
|||
|
it resolves to <a href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> then the next value will be produced.</p>
|
|||
|
<p>Note that this function consumes the stream passed into it and returns a
|
|||
|
wrapped version of it, similar to the existing <code>filter_map</code> methods in
|
|||
|
the standard library.</p>
|
|||
|
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
<span class="kw">let </span>events = stream.filter_map(|x| <span class="kw">async move </span>{
|
|||
|
<span class="kw">if </span>x % <span class="number">2 </span>== <span class="number">0 </span>{ <span class="prelude-val">Some</span>(x + <span class="number">1</span>) } <span class="kw">else </span>{ <span class="prelude-val">None </span>}
|
|||
|
});
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">9</span>, <span class="number">11</span>], events.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.then" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#488-495">source</a><h4 class="code-header">fn <a href="#method.then" class="fn">then</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.Then.html" title="struct futures_util::stream::Then">Then</a><Self, Fut, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Computes from this stream’s items new items of a different type using
|
|||
|
an asynchronous closure.</p>
|
|||
|
<p>The provided closure <code>f</code> will be called with an <code>Item</code> once a value is
|
|||
|
ready, it returns a future which will then be run to completion
|
|||
|
to produce the next value on this stream.</p>
|
|||
|
<p>Note that this function consumes the stream passed into it and returns a
|
|||
|
wrapped version of it.</p>
|
|||
|
<p>See <a href="trait.StreamExt.html#method.map"><code>StreamExt::map</code></a> if you want to use a closure that
|
|||
|
returns a value instead of a future.</p>
|
|||
|
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">3</span>);
|
|||
|
<span class="kw">let </span>stream = stream.then(|x| <span class="kw">async move </span>{ x + <span class="number">3 </span>});
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.collect" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#522-527">source</a><h4 class="code-header">fn <a href="#method.collect" class="fn">collect</a><C: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>>(self) -> <a class="struct" href="struct.Collect.html" title="struct futures_util::stream::Collect">Collect</a><Self, C> <a href="#" class="tooltip" data-notable-ty="Collect<Self, C>">ⓘ</a><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Transforms a stream into a collection, returning a
|
|||
|
future representing the result of that computation.</p>
|
|||
|
<p>The returned future will be resolved when the stream terminates.</p>
|
|||
|
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::channel::mpsc;
|
|||
|
<span class="kw">use </span>futures::stream::StreamExt;
|
|||
|
<span class="kw">use </span>std::thread;
|
|||
|
|
|||
|
<span class="kw">let </span>(tx, rx) = mpsc::unbounded();
|
|||
|
|
|||
|
thread::spawn(<span class="kw">move </span>|| {
|
|||
|
<span class="kw">for </span>i <span class="kw">in </span><span class="number">1</span>..=<span class="number">5 </span>{
|
|||
|
tx.unbounded_send(i).unwrap();
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
<span class="kw">let </span>output = rx.collect::<Vec<i32>>().<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(output, <span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.unzip" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#559-566">source</a><h4 class="code-header">fn <a href="#method.unzip" class="fn">unzip</a><A, B, FromA, FromB>(self) -> <a class="struct" href="struct.Unzip.html" title="struct futures_util::stream::Unzip">Unzip</a><Self, FromA, FromB> <a href="#" class="tooltip" data-notable-ty="Unzip<Self, FromA, FromB>">ⓘ</a><div class="where">where
|
|||
|
FromA: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><A>,
|
|||
|
FromB: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><B>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.tuple.html">(A, B)</a>>,</div></h4></section></summary><div class="docblock"><p>Converts a stream of pairs into a future, which
|
|||
|
resolves to pair of containers.</p>
|
|||
|
<p><code>unzip()</code> produces a future, which resolves to two
|
|||
|
collections: one from the left elements of the pairs,
|
|||
|
and one from the right elements.</p>
|
|||
|
<p>The returned future will be resolved when the stream terminates.</p>
|
|||
|
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::channel::mpsc;
|
|||
|
<span class="kw">use </span>futures::stream::StreamExt;
|
|||
|
<span class="kw">use </span>std::thread;
|
|||
|
|
|||
|
<span class="kw">let </span>(tx, rx) = mpsc::unbounded();
|
|||
|
|
|||
|
thread::spawn(<span class="kw">move </span>|| {
|
|||
|
tx.unbounded_send((<span class="number">1</span>, <span class="number">2</span>)).unwrap();
|
|||
|
tx.unbounded_send((<span class="number">3</span>, <span class="number">4</span>)).unwrap();
|
|||
|
tx.unbounded_send((<span class="number">5</span>, <span class="number">6</span>)).unwrap();
|
|||
|
});
|
|||
|
|
|||
|
<span class="kw">let </span>(o1, o2): (Vec<<span class="kw">_</span>>, Vec<<span class="kw">_</span>>) = rx.unzip().<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(o1, <span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>]);
|
|||
|
<span class="macro">assert_eq!</span>(o2, <span class="macro">vec!</span>[<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.concat" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#600-606">source</a><h4 class="code-header">fn <a href="#method.concat" class="fn">concat</a>(self) -> <a class="struct" href="struct.Concat.html" title="struct futures_util::stream::Concat">Concat</a><Self> <a href="#" class="tooltip" data-notable-ty="Concat<Self>">ⓘ</a><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a><<<Self as <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>>::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::collect::IntoIterator::Item">Item</a>> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section></summary><div class="docblock"><p>Concatenate all items of a stream into a single extendable
|
|||
|
destination, returning a future representing the end result.</p>
|
|||
|
<p>This combinator will extend the first item with the contents
|
|||
|
of all the subsequent results of the stream. If the stream is
|
|||
|
empty, the default value will be returned.</p>
|
|||
|
<p>Works with all collections that implement the
|
|||
|
<a href="std::iter::Extend"><code>Extend</code></a> trait.</p>
|
|||
|
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::channel::mpsc;
|
|||
|
<span class="kw">use </span>futures::stream::StreamExt;
|
|||
|
<span class="kw">use </span>std::thread;
|
|||
|
|
|||
|
<span class="kw">let </span>(tx, rx) = mpsc::unbounded();
|
|||
|
|
|||
|
thread::spawn(<span class="kw">move </span>|| {
|
|||
|
<span class="kw">for </span>i <span class="kw">in </span>(<span class="number">0</span>..<span class="number">3</span>).rev() {
|
|||
|
<span class="kw">let </span>n = i * <span class="number">3</span>;
|
|||
|
tx.unbounded_send(<span class="macro">vec!</span>[n + <span class="number">1</span>, n + <span class="number">2</span>, n + <span class="number">3</span>]).unwrap();
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
<span class="kw">let </span>result = rx.concat().<span class="kw">await</span>;
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(result, <span class="macro">vec!</span>[<span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.count" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#633-638">source</a><h4 class="code-header">fn <a href="#method.count" class="fn">count</a>(self) -> <a class="struct" href="struct.Count.html" title="struct futures_util::stream::Count">Count</a><Self> <a href="#" class="tooltip" data-notable-ty="Count<Self>">ⓘ</a><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Drives the stream to completion, counting the number of items.</p>
|
|||
|
<h5 id="overflow-behavior-1"><a class="doc-anchor" href="#overflow-behavior-1">§</a>Overflow Behavior</h5>
|
|||
|
<p>The method does no guarding against overflows, so counting elements of a
|
|||
|
stream with more than <a href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html#associatedconstant.MAX" title="associated constant usize::MAX"><code>usize::MAX</code></a> elements either produces the wrong
|
|||
|
result or panics. If debug assertions are enabled, a panic is guaranteed.</p>
|
|||
|
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
|||
|
<p>This function might panic if the iterator has more than <a href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html#associatedconstant.MAX" title="associated constant usize::MAX"><code>usize::MAX</code></a>
|
|||
|
elements.</p>
|
|||
|
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
<span class="kw">let </span>count = stream.count().<span class="kw">await</span>;
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(count, <span class="number">10</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.cycle" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#663-668">source</a><h4 class="code-header">fn <a href="#method.cycle" class="fn">cycle</a>(self) -> <a class="struct" href="struct.Cycle.html" title="struct futures_util::stream::Cycle">Cycle</a><Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class="docblock"><p>Repeats a stream endlessly.</p>
|
|||
|
<p>The stream never terminates. Note that you likely want to avoid
|
|||
|
usage of <code>collect</code> or such on the returned stream as it will exhaust
|
|||
|
available memory as it tries to just fill up all RAM.</p>
|
|||
|
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
<span class="kw">let </span>a = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>s = stream::iter(a.iter()).cycle();
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">1</span>));
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">2</span>));
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">3</span>));
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">1</span>));
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">2</span>));
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">3</span>));
|
|||
|
<span class="macro">assert_eq!</span>(s.next().<span class="kw">await</span>, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">1</span>));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.fold" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#690-697">source</a><h4 class="code-header">fn <a href="#method.fold" class="fn">fold</a><T, Fut, F>(self, init: T, f: F) -> <a class="struct" href="struct.Fold.html" title="struct futures_util::stream::Fold">Fold</a><Self, Fut, T, F> <a href="#" class="tooltip" data-notable-ty="Fold<Self, Fut, T, F>">ⓘ</a><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(T, Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = T>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Execute an accumulating asynchronous computation over a stream,
|
|||
|
collecting all the values into one final result.</p>
|
|||
|
<p>This combinator will accumulate all values returned by this stream
|
|||
|
according to the closure provided. The initial state is also provided to
|
|||
|
this method and then is returned again by each execution of the closure.
|
|||
|
Once the entire stream has been exhausted the returned future will
|
|||
|
resolve to this value.</p>
|
|||
|
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>number_stream = stream::iter(<span class="number">0</span>..<span class="number">6</span>);
|
|||
|
<span class="kw">let </span>sum = number_stream.fold(<span class="number">0</span>, |acc, x| <span class="kw">async move </span>{ acc + x });
|
|||
|
<span class="macro">assert_eq!</span>(sum.<span class="kw">await</span>, <span class="number">15</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.any" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#712-719">source</a><h4 class="code-header">fn <a href="#method.any" class="fn">any</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.Any.html" title="struct futures_util::stream::Any">Any</a><Self, Fut, F> <a href="#" class="tooltip" data-notable-ty="Any<Self, Fut, F>">ⓘ</a><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Execute predicate over asynchronous stream, and return <code>true</code> if any element in stream satisfied a predicate.</p>
|
|||
|
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>number_stream = stream::iter(<span class="number">0</span>..<span class="number">10</span>);
|
|||
|
<span class="kw">let </span>contain_three = number_stream.any(|i| <span class="kw">async move </span>{ i == <span class="number">3 </span>});
|
|||
|
<span class="macro">assert_eq!</span>(contain_three.<span class="kw">await</span>, <span class="bool-val">true</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.all" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#734-741">source</a><h4 class="code-header">fn <a href="#method.all" class="fn">all</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.All.html" title="struct futures_util::stream::All">All</a><Self, Fut, F> <a href="#" class="tooltip" data-notable-ty="All<Self, Fut, F>">ⓘ</a><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Execute predicate over asynchronous stream, and return <code>true</code> if all element in stream satisfied a predicate.</p>
|
|||
|
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>number_stream = stream::iter(<span class="number">0</span>..<span class="number">10</span>);
|
|||
|
<span class="kw">let </span>less_then_twenty = number_stream.all(|i| <span class="kw">async move </span>{ i < <span class="number">20 </span>});
|
|||
|
<span class="macro">assert_eq!</span>(less_then_twenty.<span class="kw">await</span>, <span class="bool-val">true</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.flatten" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#774-780">source</a><h4 class="code-header">fn <a href="#method.flatten" class="fn">flatten</a>(self) -> <a class="struct" href="struct.Flatten.html" title="struct futures_util::stream::Flatten">Flatten</a><Self><div class="where">where
|
|||
|
Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Flattens a stream of streams into just one continuous stream.</p>
|
|||
|
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::channel::mpsc;
|
|||
|
<span class="kw">use </span>futures::stream::StreamExt;
|
|||
|
<span class="kw">use </span>std::thread;
|
|||
|
|
|||
|
<span class="kw">let </span>(tx1, rx1) = mpsc::unbounded();
|
|||
|
<span class="kw">let </span>(tx2, rx2) = mpsc::unbounded();
|
|||
|
<span class="kw">let </span>(tx3, rx3) = mpsc::unbounded();
|
|||
|
|
|||
|
thread::spawn(<span class="kw">move </span>|| {
|
|||
|
tx1.unbounded_send(<span class="number">1</span>).unwrap();
|
|||
|
tx1.unbounded_send(<span class="number">2</span>).unwrap();
|
|||
|
});
|
|||
|
thread::spawn(<span class="kw">move </span>|| {
|
|||
|
tx2.unbounded_send(<span class="number">3</span>).unwrap();
|
|||
|
tx2.unbounded_send(<span class="number">4</span>).unwrap();
|
|||
|
});
|
|||
|
thread::spawn(<span class="kw">move </span>|| {
|
|||
|
tx3.unbounded_send(rx1).unwrap();
|
|||
|
tx3.unbounded_send(rx2).unwrap();
|
|||
|
});
|
|||
|
|
|||
|
<span class="kw">let </span>output = rx3.flatten().collect::<Vec<i32>>().<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(output, <span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.flat_map" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#858-865">source</a><h4 class="code-header">fn <a href="#method.flat_map" class="fn">flat_map</a><U, F>(self, f: F) -> <a class="struct" href="struct.FlatMap.html" title="struct futures_util::stream::FlatMap">FlatMap</a><Self, U, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> U,
|
|||
|
U: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Maps a stream like <a href="trait.StreamExt.html#method.map" title="method futures_util::stream::StreamExt::map"><code>StreamExt::map</code></a> but flattens nested <code>Stream</code>s.</p>
|
|||
|
<p><a href="trait.StreamExt.html#method.map" title="method futures_util::stream::StreamExt::map"><code>StreamExt::map</code></a> is very useful, but if it produces a <code>Stream</code> instead,
|
|||
|
you would have to chain combinators like <code>.map(f).flatten()</code> while this
|
|||
|
combinator provides ability to write <code>.flat_map(f)</code> instead of chaining.</p>
|
|||
|
<p>The provided closure which produces inner streams is executed over all elements
|
|||
|
of stream as last inner stream is terminated and next stream item is available.</p>
|
|||
|
<p>Note that this function consumes the stream passed into it and returns a
|
|||
|
wrapped version of it, similar to the existing <code>flat_map</code> methods in the
|
|||
|
standard library.</p>
|
|||
|
<h5 id="examples-16"><a class="doc-anchor" href="#examples-16">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">3</span>);
|
|||
|
<span class="kw">let </span>stream = stream.flat_map(|x| stream::iter(<span class="macro">vec!</span>[x + <span class="number">3</span>; x]));
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">6</span>, <span class="number">6</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.scan" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#944-951">source</a><h4 class="code-header">fn <a href="#method.scan" class="fn">scan</a><S, B, Fut, F>(self, initial_state: S, f: F) -> <a class="struct" href="struct.Scan.html" title="struct futures_util::stream::Scan">Scan</a><Self, S, Fut, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.reference.html">&mut S</a>, Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><B>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Combinator similar to <a href="trait.StreamExt.html#method.fold" title="method futures_util::stream::StreamExt::fold"><code>StreamExt::fold</code></a> that holds internal state
|
|||
|
and produces a new stream.</p>
|
|||
|
<p>Accepts initial state and closure which will be applied to each element
|
|||
|
of the stream until provided closure returns <code>None</code>. Once <code>None</code> is
|
|||
|
returned, stream will be terminated.</p>
|
|||
|
<h5 id="examples-17"><a class="doc-anchor" href="#examples-17">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream.scan(<span class="number">0</span>, |state, x| {
|
|||
|
<span class="kw-2">*</span>state += x;
|
|||
|
future::ready(<span class="kw">if </span><span class="kw-2">*</span>state < <span class="number">10 </span>{ <span class="prelude-val">Some</span>(x) } <span class="kw">else </span>{ <span class="prelude-val">None </span>})
|
|||
|
});
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.skip_while" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#975-982">source</a><h4 class="code-header">fn <a href="#method.skip_while" class="fn">skip_while</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.SkipWhile.html" title="struct futures_util::stream::SkipWhile">SkipWhile</a><Self, Fut, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Skip elements on this stream while the provided asynchronous predicate
|
|||
|
resolves to <code>true</code>.</p>
|
|||
|
<p>This function, like <code>Iterator::skip_while</code>, will skip elements on the
|
|||
|
stream until the predicate <code>f</code> resolves to <code>false</code>. Once one element
|
|||
|
returns <code>false</code>, all future elements will be returned from the underlying
|
|||
|
stream.</p>
|
|||
|
<h5 id="examples-18"><a class="doc-anchor" href="#examples-18">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream.skip_while(|x| future::ready(<span class="kw-2">*</span>x <= <span class="number">5</span>));
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">10</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.take_while" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1005-1012">source</a><h4 class="code-header">fn <a href="#method.take_while" class="fn">take_while</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.TakeWhile.html" title="struct futures_util::stream::TakeWhile">TakeWhile</a><Self, Fut, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.bool.html">bool</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Take elements from this stream while the provided asynchronous predicate
|
|||
|
resolves to <code>true</code>.</p>
|
|||
|
<p>This function, like <code>Iterator::take_while</code>, will take elements from the
|
|||
|
stream until the predicate <code>f</code> resolves to <code>false</code>. Once one element
|
|||
|
returns <code>false</code>, it will always return that the stream is done.</p>
|
|||
|
<h5 id="examples-19"><a class="doc-anchor" href="#examples-19">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream.take_while(|x| future::ready(<span class="kw-2">*</span>x <= <span class="number">5</span>));
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.take_until" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1050-1056">source</a><h4 class="code-header">fn <a href="#method.take_until" class="fn">take_until</a><Fut>(self, fut: Fut) -> <a class="struct" href="struct.TakeUntil.html" title="struct futures_util::stream::TakeUntil">TakeUntil</a><Self, Fut><div class="where">where
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Take elements from this stream until the provided future resolves.</p>
|
|||
|
<p>This function will take elements from the stream until the provided
|
|||
|
stopping future <code>fut</code> resolves. Once the <code>fut</code> future becomes ready,
|
|||
|
this stream combinator will always return that the stream is done.</p>
|
|||
|
<p>The stopping future may return any type. Once the stream is stopped
|
|||
|
the result of the stopping future may be accessed with <code>TakeUntil::take_result()</code>.
|
|||
|
The stream may also be resumed with <code>TakeUntil::take_future()</code>.
|
|||
|
See the documentation of <a href="struct.TakeUntil.html" title="struct futures_util::stream::TakeUntil"><code>TakeUntil</code></a> for more information.</p>
|
|||
|
<h5 id="examples-20"><a class="doc-anchor" href="#examples-20">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
<span class="kw">use </span>futures::task::Poll;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>);
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>i = <span class="number">0</span>;
|
|||
|
<span class="kw">let </span>stop_fut = future::poll_fn(|_cx| {
|
|||
|
i += <span class="number">1</span>;
|
|||
|
<span class="kw">if </span>i <= <span class="number">5 </span>{
|
|||
|
Poll::Pending
|
|||
|
} <span class="kw">else </span>{
|
|||
|
Poll::Ready(())
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream.take_until(stop_fut);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.for_each" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1091-1098">source</a><h4 class="code-header">fn <a href="#method.for_each" class="fn">for_each</a><Fut, F>(self, f: F) -> <a class="struct" href="struct.ForEach.html" title="struct futures_util::stream::ForEach">ForEach</a><Self, Fut, F> <a href="#" class="tooltip" data-notable-ty="ForEach<Self, Fut, F>">ⓘ</a><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>) -> Fut,
|
|||
|
Fut: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.unit.html">()</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Runs this stream to completion, executing the provided asynchronous
|
|||
|
closure for each element on the stream.</p>
|
|||
|
<p>The closure provided will be called for each item this stream produces,
|
|||
|
yielding a future. That future will then be executed to completion
|
|||
|
before moving on to the next item.</p>
|
|||
|
<p>The returned value is a <code>Future</code> where the <code>Output</code> type is <code>()</code>; it is
|
|||
|
executed entirely for its side effects.</p>
|
|||
|
<p>To process each item in the stream and produce another stream instead
|
|||
|
of a single future, use <code>then</code> instead.</p>
|
|||
|
<h5 id="examples-21"><a class="doc-anchor" href="#examples-21">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>x = <span class="number">0</span>;
|
|||
|
|
|||
|
{
|
|||
|
<span class="kw">let </span>fut = stream::repeat(<span class="number">1</span>).take(<span class="number">3</span>).for_each(|item| {
|
|||
|
x += item;
|
|||
|
future::ready(())
|
|||
|
});
|
|||
|
fut.<span class="kw">await</span>;
|
|||
|
}
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(x, <span class="number">3</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.take" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1176-1181">source</a><h4 class="code-header">fn <a href="#method.take" class="fn">take</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Take.html" title="struct futures_util::stream::Take">Take</a><Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Creates a new stream of at most <code>n</code> items of the underlying stream.</p>
|
|||
|
<p>Once <code>n</code> items have been yielded from this stream then it will always
|
|||
|
return that the stream is done.</p>
|
|||
|
<h5 id="examples-22"><a class="doc-anchor" href="#examples-22">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>).take(<span class="number">3</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.skip" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1199-1204">source</a><h4 class="code-header">fn <a href="#method.skip" class="fn">skip</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Skip.html" title="struct futures_util::stream::Skip">Skip</a><Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Creates a new stream which skips <code>n</code> items of the underlying stream.</p>
|
|||
|
<p>Once <code>n</code> items have been skipped from this stream then it will always
|
|||
|
return the remaining items on this stream.</p>
|
|||
|
<h5 id="examples-23"><a class="doc-anchor" href="#examples-23">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream::iter(<span class="number">1</span>..=<span class="number">10</span>).skip(<span class="number">5</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">10</span>], stream.collect::<Vec<<span class="kw">_</span>>>().<span class="kw">await</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.fuse" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1245-1250">source</a><h4 class="code-header">fn <a href="#method.fuse" class="fn">fuse</a>(self) -> <a class="struct" href="struct.Fuse.html" title="struct futures_util::stream::Fuse">Fuse</a><Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Fuse a stream such that <a href="trait.Stream.html#tymethod.poll_next" title="method futures_util::stream::Stream::poll_next"><code>poll_next</code></a> will never
|
|||
|
again be called once it has finished. This method can be used to turn
|
|||
|
any <code>Stream</code> into a <code>FusedStream</code>.</p>
|
|||
|
<p>Normally, once a stream has returned <a href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> from
|
|||
|
<a href="trait.Stream.html#tymethod.poll_next" title="method futures_util::stream::Stream::poll_next"><code>poll_next</code></a> any further calls could exhibit bad
|
|||
|
behavior such as block forever, panic, never return, etc. If it is known
|
|||
|
that <a href="trait.Stream.html#tymethod.poll_next" title="method futures_util::stream::Stream::poll_next"><code>poll_next</code></a> may be called after stream
|
|||
|
has already finished, then this method can be used to ensure that it has
|
|||
|
defined semantics.</p>
|
|||
|
<p>The <a href="trait.Stream.html#tymethod.poll_next" title="method futures_util::stream::Stream::poll_next"><code>poll_next</code></a> method of a <code>fuse</code>d stream
|
|||
|
is guaranteed to return <a href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> after the underlying stream has
|
|||
|
finished.</p>
|
|||
|
<h5 id="examples-24"><a class="doc-anchor" href="#examples-24">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::executor::block_on_stream;
|
|||
|
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
<span class="kw">use </span>futures::task::Poll;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>x = <span class="number">0</span>;
|
|||
|
<span class="kw">let </span>stream = stream::poll_fn(|<span class="kw">_</span>| {
|
|||
|
x += <span class="number">1</span>;
|
|||
|
<span class="kw">match </span>x {
|
|||
|
<span class="number">0</span>..=<span class="number">2 </span>=> Poll::Ready(<span class="prelude-val">Some</span>(x)),
|
|||
|
<span class="number">3 </span>=> Poll::Ready(<span class="prelude-val">None</span>),
|
|||
|
<span class="kw">_ </span>=> <span class="macro">panic!</span>(<span class="string">"should not happen"</span>)
|
|||
|
}
|
|||
|
}).fuse();
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>iter = block_on_stream(stream);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>), iter.next());
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">2</span>), iter.next());
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, iter.next());
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, iter.next());
|
|||
|
<span class="comment">// ...</span></code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1278-1280">source</a><h4 class="code-header">fn <a href="#method.by_ref" class="fn">by_ref</a>(&mut self) -> &mut Self</h4></section></summary><div class="docblock"><p>Borrows a stream, rather than consuming it.</p>
|
|||
|
<p>This is useful to allow applying stream adaptors while still retaining
|
|||
|
ownership of the original stream.</p>
|
|||
|
<h5 id="examples-25"><a class="doc-anchor" href="#examples-25">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>stream = stream::iter(<span class="number">1</span>..<span class="number">5</span>);
|
|||
|
|
|||
|
<span class="kw">let </span>sum = stream.by_ref()
|
|||
|
.take(<span class="number">2</span>)
|
|||
|
.fold(<span class="number">0</span>, |a, b| <span class="kw">async move </span>{ a + b })
|
|||
|
.<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(sum, <span class="number">3</span>);
|
|||
|
|
|||
|
<span class="comment">// You can use the stream again
|
|||
|
</span><span class="kw">let </span>sum = stream.take(<span class="number">2</span>)
|
|||
|
.fold(<span class="number">0</span>, |a, b| <span class="kw">async move </span>{ a + b })
|
|||
|
.<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(sum, <span class="number">7</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.zip" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1445-1451">source</a><h4 class="code-header">fn <a href="#method.zip" class="fn">zip</a><St>(self, other: St) -> <a class="struct" href="struct.Zip.html" title="struct futures_util::stream::Zip">Zip</a><Self, St><div class="where">where
|
|||
|
St: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>An adapter for zipping two streams together.</p>
|
|||
|
<p>The zipped stream waits for both streams to produce an item, and then
|
|||
|
returns that pair. If either stream ends then the zipped stream will
|
|||
|
also end.</p>
|
|||
|
<h5 id="examples-26"><a class="doc-anchor" href="#examples-26">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream1 = stream::iter(<span class="number">1</span>..=<span class="number">3</span>);
|
|||
|
<span class="kw">let </span>stream2 = stream::iter(<span class="number">5</span>..=<span class="number">10</span>);
|
|||
|
|
|||
|
<span class="kw">let </span>vec = stream1.zip(stream2)
|
|||
|
.collect::<Vec<<span class="kw">_</span>>>()
|
|||
|
.<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[(<span class="number">1</span>, <span class="number">5</span>), (<span class="number">2</span>, <span class="number">6</span>), (<span class="number">3</span>, <span class="number">7</span>)], vec);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.chain" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1476-1482">source</a><h4 class="code-header">fn <a href="#method.chain" class="fn">chain</a><St>(self, other: St) -> <a class="struct" href="struct.Chain.html" title="struct futures_util::stream::Chain">Chain</a><Self, St><div class="where">where
|
|||
|
St: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Adapter for chaining two streams.</p>
|
|||
|
<p>The resulting stream emits elements from the first stream, and when
|
|||
|
first stream reaches the end, emits the elements from the second stream.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::stream::{<span class="self">self</span>, StreamExt};
|
|||
|
|
|||
|
<span class="kw">let </span>stream1 = stream::iter(<span class="macro">vec!</span>[<span class="prelude-val">Ok</span>(<span class="number">10</span>), <span class="prelude-val">Err</span>(<span class="bool-val">false</span>)]);
|
|||
|
<span class="kw">let </span>stream2 = stream::iter(<span class="macro">vec!</span>[<span class="prelude-val">Err</span>(<span class="bool-val">true</span>), <span class="prelude-val">Ok</span>(<span class="number">20</span>)]);
|
|||
|
|
|||
|
<span class="kw">let </span>stream = stream1.chain(stream2);
|
|||
|
|
|||
|
<span class="kw">let </span>result: Vec<<span class="kw">_</span>> = stream.collect().<span class="kw">await</span>;
|
|||
|
<span class="macro">assert_eq!</span>(result, <span class="macro">vec!</span>[
|
|||
|
<span class="prelude-val">Ok</span>(<span class="number">10</span>),
|
|||
|
<span class="prelude-val">Err</span>(<span class="bool-val">false</span>),
|
|||
|
<span class="prelude-val">Err</span>(<span class="bool-val">true</span>),
|
|||
|
<span class="prelude-val">Ok</span>(<span class="number">20</span>),
|
|||
|
]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.peekable" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1487-1492">source</a><h4 class="code-header">fn <a href="#method.peekable" class="fn">peekable</a>(self) -> <a class="struct" href="struct.Peekable.html" title="struct futures_util::stream::Peekable">Peekable</a><Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Creates a new stream which exposes a <code>peek</code> method.</p>
|
|||
|
<p>Calling <code>peek</code> returns a reference to the next item in the stream.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.inspect" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1598-1604">source</a><h4 class="code-header">fn <a href="#method.inspect" class="fn">inspect</a><F>(self, f: F) -> <a class="struct" href="struct.Inspect.html" title="struct futures_util::stream::Inspect">Inspect</a><Self, F><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>),
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Do something with each item of this stream, afterwards passing it on.</p>
|
|||
|
<p>This is similar to the <code>Iterator::inspect</code> method in the standard
|
|||
|
library where it allows easily inspecting each value as it passes
|
|||
|
through the stream, for example to debug what’s going on.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.left_stream" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1611-1617">source</a><h4 class="code-header">fn <a href="#method.left_stream" class="fn">left_stream</a><B>(self) -> <a class="enum" href="../future/enum.Either.html" title="enum futures_util::future::Either">Either</a><Self, B> <a href="#" class="tooltip" data-notable-ty="Either<Self, B>">ⓘ</a><div class="where">where
|
|||
|
B: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Wrap this stream in an <code>Either</code> stream, making it the left-hand variant
|
|||
|
of that <code>Either</code>.</p>
|
|||
|
<p>This can be used in combination with the <code>right_stream</code> method to write <code>if</code>
|
|||
|
statements that evaluate to different streams in different branches.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.right_stream" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1624-1630">source</a><h4 class="code-header">fn <a href="#method.right_stream" class="fn">right_stream</a><B>(self) -> <a class="enum" href="../future/enum.Either.html" title="enum futures_util::future::Either">Either</a><B, Self> <a href="#" class="tooltip" data-notable-ty="Either<B, Self>">ⓘ</a><div class="where">where
|
|||
|
B: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a><Item = Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Wrap this stream in an <code>Either</code> stream, making it the right-hand variant
|
|||
|
of that <code>Either</code>.</p>
|
|||
|
<p>This can be used in combination with the <code>left_stream</code> method to write <code>if</code>
|
|||
|
statements that evaluate to different streams in different branches.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.poll_next_unpin" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1634-1639">source</a><h4 class="code-header">fn <a href="#method.poll_next_unpin" class="fn">poll_next_unpin</a>(&mut self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/1.83.0/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self::<a class="associatedtype" href="trait.Stream.html#associatedtype.Item" title="type futures_util::stream::Stream::Item">Item</a>>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class="docblock"><p>A convenience method for calling <a href="trait.Stream.html#tymethod.poll_next" title="method futures_util::stream::Stream::poll_next"><code>Stream::poll_next</code></a> on <a href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin"><code>Unpin</code></a>
|
|||
|
stream types.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.select_next_some" class="method"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#1691-1696">source</a><h4 class="code-header">fn <a href="#method.select_next_some" class="fn">select_next_some</a>(&mut self) -> <a class="struct" href="struct.SelectNextSome.html" title="struct futures_util::stream::SelectNextSome">SelectNextSome</a><'_, Self> <a href="#" class="tooltip" data-notable-ty="SelectNextSome<'_, Self>">ⓘ</a><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="trait.FusedStream.html" title="trait futures_util::stream::FusedStream">FusedStream</a>,</div></h4></section></summary><div class="docblock"><p>Returns a <a href="https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> that resolves when the next item in this stream is
|
|||
|
ready.</p>
|
|||
|
<p>This is similar to the <a href="trait.StreamExt.html#method.next" title="method futures_util::stream::StreamExt::next"><code>next</code></a> method, but it won’t
|
|||
|
resolve to <a href="https://doc.rust-lang.org/1.83.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> if used on an empty <a href="trait.Stream.html" title="trait futures_util::stream::Stream"><code>Stream</code></a>. Instead, the
|
|||
|
returned future type will return <code>true</code> from
|
|||
|
<a href="../future/trait.FusedFuture.html#tymethod.is_terminated" title="method futures_util::future::FusedFuture::is_terminated"><code>FusedFuture::is_terminated</code></a> when the <a href="trait.Stream.html" title="trait futures_util::stream::Stream"><code>Stream</code></a> is empty, allowing
|
|||
|
<a href="trait.StreamExt.html#method.select_next_some" title="method futures_util::stream::StreamExt::select_next_some"><code>select_next_some</code></a> to be easily used with
|
|||
|
the <a href="crate::select"><code>select!</code></a> macro.</p>
|
|||
|
<p>If the future is polled after this <a href="trait.Stream.html" title="trait futures_util::stream::Stream"><code>Stream</code></a> is empty it will panic.
|
|||
|
Using the future with a <a href="../future/trait.FusedFuture.html" title="trait futures_util::future::FusedFuture"><code>FusedFuture</code></a>-aware primitive like the
|
|||
|
<a href="crate::select"><code>select!</code></a> macro will prevent this.</p>
|
|||
|
<h5 id="examples-27"><a class="doc-anchor" href="#examples-27">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::{future, select};
|
|||
|
<span class="kw">use </span>futures::stream::{StreamExt, FuturesUnordered};
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>fut = future::ready(<span class="number">1</span>);
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>async_tasks = FuturesUnordered::new();
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>total = <span class="number">0</span>;
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="macro">select!</span> {
|
|||
|
num = fut => {
|
|||
|
<span class="comment">// First, the `ready` future completes.
|
|||
|
</span>total += num;
|
|||
|
<span class="comment">// Then we spawn a new task onto `async_tasks`,
|
|||
|
</span>async_tasks.push(<span class="kw">async </span>{ <span class="number">5 </span>});
|
|||
|
},
|
|||
|
<span class="comment">// On the next iteration of the loop, the task we spawned
|
|||
|
// completes.
|
|||
|
</span>num = async_tasks.select_next_some() => {
|
|||
|
total += num;
|
|||
|
}
|
|||
|
<span class="comment">// Finally, both the `ready` future and `async_tasks` have
|
|||
|
// finished, so we enter the `complete` branch.
|
|||
|
</span>complete => <span class="kw">break</span>,
|
|||
|
}
|
|||
|
}
|
|||
|
<span class="macro">assert_eq!</span>(total, <span class="number">6</span>);</code></pre></div>
|
|||
|
</div></details></div><h2 id="object-safety" class="section-header">Object Safety<a href="#object-safety" class="anchor">§</a></h2><div class="object-safety-info">This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.83.0/reference/items/traits.html#object-safety">object safe</a>.</div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-StreamExt-for-T" class="impl"><a class="src rightside" href="../../src/futures_util/stream/stream/mod.rs.html#245">source</a><a href="#impl-StreamExt-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.StreamExt.html" title="trait futures_util::stream::StreamExt">StreamExt</a> for T<div class="where">where
|
|||
|
T: <a class="trait" href="trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></div><script src="../../trait.impl/futures_util/stream/stream/trait.StreamExt.js" async></script><script type="text/json" id="notable-traits-data">{"All<Self, Fut, F>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.All.html\" title=\"struct futures_util::stream::All\">All</a><St, Fut, F></code></h3><pre><code><div class=\"where\">impl<St, Fut, F> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.All.html\" title=\"struct futures_util::stream::All\">All</a><St, Fut, F><div class=\"where\">where\n St: <a class=\"trait\" href=\"trait.Stream.html\" title=\"trait futures_util::stream::Stream\">Stream</a>,\n F: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html\" title=\"trait core::ops::function::FnMut\">FnMut</a>(St::<a class=\"associatedtype\" href=\"trait.Stream.html#associatedtype.Item\" title=\"type futures_util::stream::Stream::Item\">Item</a>) -> Fut,\n Fut: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a><Output = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.83.0/core/primitive.bool.html\">bool</a>>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.83.0/core/primitive.bool.html\">bool</a>;</div>","Any<Self, Fut, F>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Any.html\" title=\"struct futures_util::stream::Any\">Any</a><St, Fut, F></code></h3><pre><code><div class=\"where\">impl<St, Fut, F> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Any.html\" title=\"struct futures_util::stream::Any\">Any</a><St, Fut, F><div class=\"where\">where\n St: <a class=\"trait\" href=\"trait.Stream.html\" title=\"trait futures_util::stream::Stream\">Stream</a>,\n F: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnMut.html\" title=\"trait core::ops::function::FnMut\">FnMut</a>(St::<a class=\"associatedtype\" href=\"trait.Stream.html#associatedtype.Item\" title=\"type futures_util::stream::Stream::Item\">Item</a>) -> Fut,\n Fut: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a><Output = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.83.0/core/primitive.bool.html\">bool</a>>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.83.0/core/primitive.bool.html\">bool</a>;</div>","Collect<Self, C>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Collect.html\" title=\"struct futures_util::stream::Collect\">Collect</a><St, C></code></h3><pre><code><div class=\"where\">impl<St, C> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Collect.html\" title=\"struct futures_util::stream::Collect\">Collect</a><St, C><div class=\"where\">where\n St: <a class=\"trait\" href=\"trait.Stream.html\" title=\"trait futures_util::stream::Stream\">Stream</a>,\n C:
|