stream: add inner stream accessors to adaptors (#8272)

This commit is contained in:
Rachit2323
2026-08-09 18:11:51 +02:00
committed by GitHub
parent d4fb4bb9e6
commit d4569bb550
10 changed files with 386 additions and 0 deletions
+26
View File
@@ -31,6 +31,32 @@ impl<St, F> Filter<St, F> {
pub(super) fn new(stream: St, f: F) -> Self {
Self { stream, f }
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F> Stream for Filter<St, F>
+26
View File
@@ -31,6 +31,32 @@ impl<St, F> FilterMap<St, F> {
pub(super) fn new(stream: St, f: F) -> Self {
Self { stream, f }
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F, T> Stream for FilterMap<St, F>
+26
View File
@@ -29,6 +29,32 @@ impl<St, F> Map<St, F> {
pub(super) fn new(stream: St, f: F) -> Self {
Map { stream, f }
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F, T> Stream for Map<St, F>
+26
View File
@@ -37,6 +37,32 @@ impl<St, F> MapWhile<St, F> {
done: false,
}
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F, T> Stream for MapWhile<St, F>
+26
View File
@@ -31,6 +31,32 @@ impl<St> Skip<St> {
pub(super) fn new(stream: St, remaining: usize) -> Self {
Self { stream, remaining }
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St> Stream for Skip<St>
+26
View File
@@ -34,6 +34,32 @@ impl<St, F> SkipWhile<St, F> {
predicate: Some(predicate),
}
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F> Stream for SkipWhile<St, F>
+26
View File
@@ -32,6 +32,32 @@ impl<St> Take<St> {
pub(super) fn new(stream: St, remaining: usize) -> Self {
Self { stream, remaining }
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St> Stream for Take<St>
+26
View File
@@ -37,6 +37,32 @@ impl<St, F> TakeWhile<St, F> {
done: false,
}
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F> Stream for TakeWhile<St, F>
+26
View File
@@ -38,6 +38,32 @@ impl<St, Fut, F> Then<St, Fut, F> {
f,
}
}
/// Returns a reference to the inner stream.
pub fn get_ref(&self) -> &St {
&self.stream
}
/// Returns a mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_mut(&mut self) -> &mut St {
&mut self.stream
}
/// Returns a pinned mutable reference to the inner stream.
///
/// Mutating the inner stream may confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.project().stream
}
/// Consumes this combinator and returns the inner stream.
///
/// This may discard intermediate combinator state.
pub fn into_inner(self) -> St {
self.stream
}
}
impl<St, F, Fut> Stream for Then<St, Fut, F>