pub fn next_if<F>(self: Pin<&mut Self>, func: F) -> NextIf<'_, St, F>
    where
        F: FnOnce(&St::Item) -> bool,
    {
        NextIf { inner: Some((self, func)) }
    }
Creates a future which will consume and return the next value of this
stream if a condition is true.

If `func` returns `true` for the next value of this stream, consume and
return it. Otherwise, return `None`.

# Examples

Consume a number if it's equal to 0.

```
# futures::executor::block_on(async {
use core::pin::pin;

use futures::stream;
use futures::stream::StreamExt;

let stream = stream::iter(0..5).peekable();
let mut stream = pin!(stream);
// The first item of the stream is 0; consume it.
assert_eq!(stream.as_mut().next_if(|&x| x == 0).await, Some(0));
// The next item returned is now 1, so `consume` will return `false`.
assert_eq!(stream.as_mut().next_if(|&x| x == 0).await, None);
// `next_if` saves the value of the next item if it was not equal to `expected`.
assert_eq!(stream.next().await, Some(1));
# });
```

Consume any number less than 10.

```
# futures::executor::block_on(async {
use core::pin::pin;

use futures::stream;
use futures::stream::StreamExt;

let stream = stream::iter(1..20).peekable();
let mut stream = pin!(stream);
// Consume all numbers less than 10
while stream.as_mut().next_if(|&x| x < 10).await.is_some() {}
// The next value returned will be 10
assert_eq!(stream.next().await, Some(10));
# });
```
futures-util/src/stream/stream/peek.rs