pub struct AsyncIter<'a, T>(/* private fields */);
Expand description
Send
stream implemented using async functions.
This type implements Send
.
Implementations§
Source§impl<'a, T: Send + 'a> AsyncIter<'a, T>
impl<'a, T: Send + 'a> AsyncIter<'a, T>
Sourcepub fn new<Fut: Future<Output = ()> + Send + Sync + 'a>(
f: impl FnOnce(AsyncIterContext<T>) -> Fut + Send + Sync,
) -> Self
pub fn new<Fut: Future<Output = ()> + Send + Sync + 'a>( f: impl FnOnce(AsyncIterContext<T>) -> Fut + Send + Sync, ) -> Self
Create a stream from an asynchronous function.
§Example
use yield_return::AsyncIter;
let iter = AsyncIter::new(|mut y| async move {
y.ret(1).await;
y.ret(2).await;
});
let list: Vec<_> = futures::StreamExt::collect(iter).await;
assert_eq!(list, vec![1, 2]);
Trait Implementations§
Source§impl<T> FusedStream for AsyncIter<'_, T>
impl<T> FusedStream for AsyncIter<'_, T>
Source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns
true
if the stream should no longer be polled.Source§impl<T> Stream for AsyncIter<'_, T>
impl<T> Stream for AsyncIter<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for AsyncIter<'a, T>
impl<'a, T> !RefUnwindSafe for AsyncIter<'a, T>
impl<'a, T> Send for AsyncIter<'a, T>where
T: Send,
impl<'a, T> Sync for AsyncIter<'a, T>where
T: Send,
impl<'a, T> Unpin for AsyncIter<'a, T>
impl<'a, T> !UnwindSafe for AsyncIter<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more