fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
    where
        F: FnMut(&Self::Item) -> Fut,
        Fut: Future<Output = bool>,
        Self: Sized,
    {
        assert_stream::<Self::Item, _>(TakeWhile::new(self, f))
    }
Take elements from this stream while the provided asynchronous predicate
resolves to `true`.

This function, like `Iterator::take_while`, will take elements from the
stream until the predicate `f` resolves to `false`. Once one element
returns `false`, it will always return that the stream is done.

# Examples

```
# futures::executor::block_on(async {
use futures::future;
use futures::stream::{self, StreamExt};

let stream = stream::iter(1..=10);

let stream = stream.take_while(|x| future::ready(*x <= 5));

assert_eq!(vec![1, 2, 3, 4, 5], stream.collect::<Vec<_>>().await);
# });
```
futures-util/src/stream/stream/mod.rs