2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-03-01 15:49:41 +00:00

Only one generic type needed

This commit is contained in:
Felipe Sere 2019-11-01 22:57:32 -05:00
parent eaa56580e3
commit 9ee804f9ed
2 changed files with 12 additions and 8 deletions

View file

@ -7,11 +7,15 @@ use crate::task::{Context, Poll};
pin_project! { pin_project! {
/// A stream that will repeatedly yield the same list of elements /// A stream that will repeatedly yield the same list of elements
pub struct Cycle<S, T> { pub struct Cycle<S>
where
S: Stream,
S::Item: Clone,
{
#[pin] #[pin]
source: S, source: S,
index: usize, index: usize,
buffer: Vec<T>, buffer: Vec<S::Item>,
state: CycleState, state: CycleState,
} }
} }
@ -22,12 +26,12 @@ enum CycleState {
FromBuffer, FromBuffer,
} }
impl<S> Cycle<S, S::Item> impl<S> Cycle<S>
where where
S: Stream, S: Stream,
S::Item: Clone, S::Item: Clone,
{ {
pub fn new(source: S) -> Cycle<S, S::Item> { pub fn new(source: S) -> Cycle<S> {
Cycle { Cycle {
source, source,
index: 0, index: 0,
@ -37,10 +41,10 @@ where
} }
} }
impl<S, T> Stream for Cycle<S, T> impl<S> Stream for Cycle<S>
where where
S: Stream<Item = T>, S: Stream,
T: Clone, S::Item: Clone,
{ {
type Item = S::Item; type Item = S::Item;

View file

@ -435,7 +435,7 @@ extension_trait! {
# }) # })
``` ```
"#] "#]
fn cycle(self) -> Cycle<Self, Self::Item> fn cycle(self) -> Cycle<Self>
where where
Self: Sized, Self: Sized,
Self::Item: Clone, Self::Item: Clone,