/// Create a new `WatchStream` that waits for the value to be changed. pubfn from_changes(rx: Receiver<T>) -> Self { Self {
inner: ReusableBoxFuture::new(make_future(rx)),
}
}
}
impl<T: Clone + 'static + Send + Sync> Stream for WatchStream<T> { type Item = T;
fn poll_next(mutself: Pin<&mutSelf>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { let (result, mut rx) = ready!(self.inner.poll(cx)); match result {
Ok(_) => { let received = (*rx.borrow_and_update()).clone(); self.inner.set(make_future(rx));
Poll::Ready(Some(received))
}
Err(_) => { self.inner.set(make_future(rx));
Poll::Ready(None)
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.