Skip to content

Commit

Permalink
Add accessors for the inner of stream::Iter (#2875)
Browse files Browse the repository at this point in the history
  • Loading branch information
wfraser authored Sep 14, 2024
1 parent 3a8dc66 commit 4befac9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions futures-util/src/stream/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ pub struct Iter<I> {
iter: I,
}

impl<I> Iter<I> {
/// Acquires a reference to the underlying iterator that this stream is pulling from.
pub fn get_ref(&self) -> &I {
&self.iter
}

/// Acquires a mutable reference to the underlying iterator that this stream is pulling from.
pub fn get_mut(&mut self) -> &mut I {
&mut self.iter
}

/// Consumes this stream, returning the underlying iterator.
pub fn into_inner(self) -> I {
self.iter
}
}

impl<I> Unpin for Iter<I> {}

/// Converts an `Iterator` into a `Stream` which is always ready
Expand Down

0 comments on commit 4befac9

Please sign in to comment.