|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
use core::cmp::{Ord, Ordering};
|
|
|
|
|
use core::marker::PhantomData;
|
|
|
|
|
use core::pin::Pin;
|
|
|
|
|
use core::future::Future;
|
|
|
|
|
use core::pin::Pin;
|
|
|
|
|
|
|
|
|
|
use pin_project_lite::pin_project;
|
|
|
|
|
|
|
|
|
@ -11,29 +10,23 @@ use crate::task::{Context, Poll};
|
|
|
|
|
pin_project! {
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[allow(missing_debug_implementations)]
|
|
|
|
|
pub struct MaxFuture<S, F, T> {
|
|
|
|
|
pub struct MaxFuture<S, T> {
|
|
|
|
|
#[pin]
|
|
|
|
|
stream: S,
|
|
|
|
|
_compare: PhantomData<F>,
|
|
|
|
|
max: Option<T>,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<S, F, T> MaxFuture<S, F, T> {
|
|
|
|
|
impl<S, T> MaxFuture<S, T> {
|
|
|
|
|
pub(super) fn new(stream: S) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
stream,
|
|
|
|
|
_compare: PhantomData,
|
|
|
|
|
max: None,
|
|
|
|
|
}
|
|
|
|
|
Self { stream, max: None }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<S, F> Future for MaxFuture<S, F, S::Item>
|
|
|
|
|
impl<S> Future for MaxFuture<S, S::Item>
|
|
|
|
|
where
|
|
|
|
|
S: Stream,
|
|
|
|
|
S::Item: Ord,
|
|
|
|
|
F: FnMut(&S::Item, &S::Item) -> Ordering,
|
|
|
|
|
{
|
|
|
|
|
type Output = Option<S::Item>;
|
|
|
|
|
|
|
|
|
|