pub struct LocalAsyncIter<'a, T>(/* private fields */);
Expand description
Non-Send
stream implemented using async functions.
This type does not implement Send
.
Implementations§
Source§impl<'a, T: 'a> LocalAsyncIter<'a, T>
impl<'a, T: 'a> LocalAsyncIter<'a, T>
Sourcepub fn new<Fut: Future<Output = ()> + 'a>(
f: impl FnOnce(LocalAsyncIterContext<T>) -> Fut,
) -> Self
pub fn new<Fut: Future<Output = ()> + 'a>( f: impl FnOnce(LocalAsyncIterContext<T>) -> Fut, ) -> Self
Create a stream from an asynchronous function.
§Example
use yield_return::LocalAsyncIter;
let iter = LocalAsyncIter::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 LocalAsyncIter<'_, T>
impl<T> FusedStream for LocalAsyncIter<'_, 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 LocalAsyncIter<'_, T>
impl<T> Stream for LocalAsyncIter<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for LocalAsyncIter<'a, T>
impl<'a, T> !RefUnwindSafe for LocalAsyncIter<'a, T>
impl<'a, T> !Send for LocalAsyncIter<'a, T>
impl<'a, T> !Sync for LocalAsyncIter<'a, T>
impl<'a, T> Unpin for LocalAsyncIter<'a, T>
impl<'a, T> !UnwindSafe for LocalAsyncIter<'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