asynciter 0.1.0

Asynchronous iterator.
Documentation
use std::future::Future;

use crate::AsyncIterator;

#[must_use = "iterators are lazy and do nothing unless consumed"]
#[derive(Debug, Clone)]
pub struct Awaited<I> {
    inner: I,
}

impl<I> Awaited<I> {
    #[inline]
    pub fn new(inner: I) -> Awaited<I> {
        Self { inner }
    }
}

impl<I, F, B> AsyncIterator for Awaited<I>
where
    I: AsyncIterator<Item = F>,
    F: Future<Output = B>,
{
    type Item = B;

    async fn next(&mut self) -> Option<Self::Item> {
        match self.inner.next().await {
            Some(s) => Some(s.await),
            None => None,
        }
    }

    fn size_hint(&self) -> (usize, Option<usize>) {
        self.inner.size_hint()
    }
}