Skip to content

Commit dea1b67

Browse files
committed
Skeleton cycle
1 parent fa91d7f commit dea1b67

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/stream/stream/cycle.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::pin::Pin;
2+
3+
use pin_project_lite::pin_project;
4+
5+
use crate::stream::Stream;
6+
use crate::task::{Context, Poll};
7+
8+
/// A stream that will repeatedly yield the same list of elements
9+
pub struct Cycle<T> {
10+
source: Vec<T>,
11+
index: usize,
12+
}
13+
14+
impl<T: Copy> Stream for Cycle<T> {
15+
type Item = T;
16+
17+
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
18+
Poll::Pending
19+
}
20+
}

src/stream/stream/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
mod all;
2525
mod any;
2626
mod chain;
27-
mod cmp;
28-
mod copied;
2927
mod enumerate;
28+
mod cycle;
29+
mod copied;
30+
mod cmp;
3031
mod eq;
3132
mod filter;
3233
mod filter_map;

0 commit comments

Comments
 (0)