From 6f89c8b49c5fe0b2c4eaeefb1ee5ed844dcd8af9 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Wed, 5 Jun 2024 20:21:47 -0700 Subject: [PATCH] m: Rename take_until to stop_after_future This should hopefully make it more clear that this is not a carried-over "Iterator" method and is very stream-specific. Signed-off-by: John Nunley --- src/stream.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/stream.rs b/src/stream.rs index 77378b4..ed84112 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -670,12 +670,12 @@ impl Stream for OnceFuture { /// this stream combinator will always return that the stream is done. /// /// The stopping future may return any type. Once the stream is stopped -/// the result of the stopping future may be accessed with `TakeUntil::take_result()`. -/// The stream may also be resumed with `TakeUntil::take_future()`. -/// See the documentation of [`TakeUntil`] for more information. +/// the result of the stopping future may be accessed with `StopAfterFuture::take_result()`. +/// The stream may also be resumed with `StopAfterFuture::take_future()`. +/// See the documentation of [`StopAfterFuture`] for more information. /// /// ``` -/// use futures_lite::stream::{self, StreamExt, take_until}; +/// use futures_lite::stream::{self, StreamExt, stop_after_future}; /// use futures_lite::future; /// use std::task::Poll; /// @@ -692,16 +692,16 @@ impl Stream for OnceFuture { /// } /// }); /// -/// let stream = take_until(stream, stop_fut); +/// let stream = stop_after_future(stream, stop_fut); /// /// assert_eq!(vec![1, 2, 3, 4, 5], stream.collect::>().await); /// # }); -pub fn take_until(stream: S, future: F) -> TakeUntil +pub fn stop_after_future(stream: S, future: F) -> StopAfterFuture where S: Sized + Stream, F: Future, { - TakeUntil { + StopAfterFuture { stream, fut: Some(future), fut_result: None, @@ -710,10 +710,10 @@ where } pin_project! { - /// Stream for the [`StreamExt::take_until()`] method. + /// Stream for the [`StreamExt::stop_after_future()`] method. #[derive(Clone, Debug)] #[must_use = "streams do nothing unless polled"] - pub struct TakeUntil { + pub struct StopAfterFuture { #[pin] stream: S, // Contains the inner Future on start and None once the inner Future is resolved @@ -727,7 +727,7 @@ pin_project! { } } -impl TakeUntil +impl StopAfterFuture where St: Stream, Fut: Future, @@ -758,7 +758,7 @@ where /// /// ``` /// # spin_on::spin_on(async { - /// use futures_lite::stream::{self, StreamExt, take_until}; + /// use futures_lite::stream::{self, StreamExt, stop_after_future}; /// use futures_lite::future; /// use std::task::Poll; /// @@ -774,7 +774,7 @@ where /// } /// }); /// - /// let mut stream = take_until(stream, stop_fut); + /// let mut stream = stop_after_future(stream, stop_fut); /// let _ = (&mut stream).collect::>().await; /// /// let result = stream.take_result().unwrap(); @@ -792,7 +792,7 @@ where } } -impl Stream for TakeUntil +impl Stream for StopAfterFuture where St: Stream, Fut: Future,