Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ use core::sync::atomic::Ordering::Relaxed;

/// Mutable iterator over all streams in the unordered set.
#[derive(Debug)]
pub struct IterPinMutWithToken<'a, S> {
pub struct IterPinMutWithToken<'a, S: 'static> {
pub(super) task: *const Task<S>,
pub(super) len: usize,
pub(super) _marker: PhantomData<&'a mut StreamUnordered<S>>,
}

/// Mutable iterator over all streams in the unordered set.
#[derive(Debug)]
pub struct IterPinMut<'a, S>(pub(super) IterPinMutWithToken<'a, S>);
pub struct IterPinMut<'a, S: 'static>(pub(super) IterPinMutWithToken<'a, S>);

/// Mutable iterator over all streams in the unordered set.
#[derive(Debug)]
pub struct IterMutWithToken<'a, S: Unpin>(pub(super) IterPinMutWithToken<'a, S>);
pub struct IterMutWithToken<'a, S: Unpin + 'static>(pub(super) IterPinMutWithToken<'a, S>);

/// Mutable iterator over all streams in the unordered set.
#[derive(Debug)]
pub struct IterMut<'a, S: Unpin>(pub(super) IterPinMutWithToken<'a, S>);
pub struct IterMut<'a, S: Unpin + 'static>(pub(super) IterPinMutWithToken<'a, S>);

/// Immutable iterator over all streams in the unordered set.
#[derive(Debug)]
pub struct IterWithToken<'a, S> {
pub struct IterWithToken<'a, S: 'static> {
pub(super) task: *const Task<S>,
pub(super) len: usize,
pub(super) pending_next_all: *mut Task<S>,
Expand Down Expand Up @@ -104,7 +104,7 @@ impl<'a, S: Unpin> Iterator for IterMutWithToken<'a, S> {

impl<S: Unpin> ExactSizeIterator for IterMutWithToken<'_, S> {}

impl<'a, S> Iterator for IterWithToken<'a, S> {
impl<'a, S:'static> Iterator for IterWithToken<'a, S> {
type Item = (&'a S, usize);

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -131,4 +131,4 @@ impl<'a, S> Iterator for IterWithToken<'a, S> {
}
}

impl<S> ExactSizeIterator for IterWithToken<'_, S> {}
impl<S: 'static> ExactSizeIterator for IterWithToken<'_, S> {}
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const YIELD_EVERY: usize = 32;
/// [`collect`](Iterator::collect) method, or you can start with an empty set
/// with the [`StreamUnordered::new`] constructor.
#[must_use = "streams do nothing unless polled"]
pub struct StreamUnordered<S> {
pub struct StreamUnordered<S: 'static> {
ready_to_run_queue: Arc<ReadyToRunQueue<S>>,
head_all: AtomicPtr<Task<S>>,
is_terminated: AtomicBool,
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<S> Unpin for StreamUnordered<S> {}
///
/// `StreamEntry` allows constructing streams that hold the token that they will be assigned.
#[derive(Debug)]
pub struct StreamEntry<'a, S> {
pub struct StreamEntry<'a, S: 'static> {
token: usize,
inserted: bool,
backref: &'a mut StreamUnordered<S>,
Expand Down Expand Up @@ -167,7 +167,7 @@ impl<'a, S: 'a> StreamEntry<'a, S> {
}
}

impl<'a, S: 'a> Drop for StreamEntry<'a, S> {
impl<'a, S: 'a + 'static> Drop for StreamEntry<'a, S> {
fn drop(&mut self) {
if !self.inserted {
// undo the insertion
Expand Down Expand Up @@ -226,7 +226,7 @@ impl<S: Stream> Default for StreamUnordered<S> {
}
}

impl<S> StreamUnordered<S> {
impl<S: 'static> StreamUnordered<S> {
/// Returns the number of streams contained in the set.
///
/// This represents the total number of in-flight streams.
Expand Down Expand Up @@ -636,7 +636,7 @@ impl<S> StreamUnordered<S> {
}
}

impl<S> Index<usize> for StreamUnordered<S> {
impl<S: 'static> Index<usize> for StreamUnordered<S> {
type Output = S;

fn index(&self, stream: usize) -> &Self::Output {
Expand Down Expand Up @@ -836,7 +836,7 @@ impl<S: Stream> Stream for StreamUnordered<S> {
// * We unlink the task from our internal queue to preemptively
// assume it'll panic, in which case we'll want to discard it
// regardless.
struct Bomb<'a, S> {
struct Bomb<'a, S: 'static> {
queue: &'a mut StreamUnordered<S>,
task: Option<Arc<Task<S>>>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<S> ArcWake for Task<S> {
}
}

impl<S> Task<S> {
impl<S: 'static> Task<S> {
/// Returns a waker reference for this task without cloning the Arc.
pub(super) fn waker_ref(this: &Arc<Task<S>>) -> WakerRef<'_> {
waker_ref(this)
Expand Down