#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, unreachable_pub)]
mod lend;
mod lend_mut;
mod next;
use std::task::{Context, Poll};
pub use lend::Lend;
pub use lend_mut::LendMut;
pub use next::Next;
use futures_core::Stream;
pub mod prelude {
pub use super::LendingStream;
pub use super::StreamExt as _;
}
pub trait StreamExt: Stream {
fn lend(self) -> Lend<Self>
where
Self: Sized + Unpin,
{
Lend::new(self)
}
fn lend_mut(self) -> LendMut<Self>
where
Self: Sized + Unpin,
{
LendMut::new(self)
}
}
impl<S: Stream> StreamExt for S {}
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub trait LendingStream {
type Item<'a>
where
Self: 'a;
fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item<'_>>>;
fn size_hint(&self) -> (usize, Option<usize>) {
(0, None)
}
fn next(&mut self) -> Next<'_, Self>
where
Self: Unpin,
{
Next::new(self)
}
}