asynciter 0.1.0

Asynchronous iterator.
Documentation
use crate::AsyncIterator;

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

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

impl<'a, I, T> AsyncIterator for Copied<I>
where
    I: AsyncIterator<Item = &'a T>,
    T: Copy + 'a,
{
    type Item = T;

    async fn next(&mut self) -> Option<T> {
        self.inner.next().await.copied()
    }

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