use core::{marker::PhantomData, pin::Pin, task::Poll};

use futures::{Stream, StreamExt};

#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct PhantonRefStream<S, G> {
    pub(crate) stream: S,
    pub(crate) _marker: PhantomData<G>,
}

impl<S, G> Unpin for PhantonRefStream<S, G> where S: Stream + Unpin {}

impl<S, G> Stream for PhantonRefStream<S, G>
where
    S: Stream + Unpin,
{
    type Item = S::Item;
    fn poll_next(
        mut self: Pin<&mut Self>,
        cx: &mut std::task::Context<'_>,
    ) -> Poll<Option<Self::Item>> {
        self.stream.poll_next_unpin(cx)
    }
    fn size_hint(&self) -> (usize, Option<usize>) {
        self.stream.size_hint()
    }
}
