Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream::repeat_item #326

Merged
merged 1 commit into from Jan 3, 2017

Conversation

Projects
None yet
3 participants
@stepancheg
Copy link
Contributor

stepancheg commented Jan 2, 2017

Procuces the same cloned element forever.

stream::repeat name would mimic iter::repeat, however,
stream::repeat with Result param is not possible usually, because
most error types (e. g. io::Error) are not Clone. Hence the
name repeat_item.

stream::repeat
Procuces the same cloned element forever.

`stream::repeat` name mimics `iter::repeat`, however,
`stream::repeat` with `Result` param is not possible usually, because
most error types (e. g. `io::Error`) are not `Clone`. So `repeat`
accepts item as param, not `Result`.
@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 3, 2017

I suspect that 99% of usage of this function would be to repeat something akin to Ok(T), so I wouldn't mind calling this repeat. We could even add repeat_err later if we really wanted to, but I suspect it won't ever come to that.

@Stebalien

This comment has been minimized.

Copy link
Contributor

Stebalien commented Jan 3, 2017

Hmm... before posting an RFC issue, do you think a From<T> for Result<T, E> impl would be useful? This seems like something that has come up several times in futures-rs discussions. Unfortunately, the fact that default types for generics don't influence inference may make less useful in cases like this.

@stepancheg stepancheg force-pushed the stepancheg:stream-repeat branch 2 times, most recently from 6e8c5be to e1371d7 Jan 3, 2017

@stepancheg

This comment has been minimized.

Copy link
Contributor Author

stepancheg commented Jan 3, 2017

Renamed repeat_item to repeat.


/// Stream that produces the same element repeatedly.
#[must_use = "streams do nothing unless polled"]
pub struct RepeatStream<T, E>

This comment has been minimized.

@alexcrichton

alexcrichton Jan 3, 2017

Member

Could this be called Repeat instead? I see that IterStream doesn't follow this convention but I think that may be a mistake.

@stepancheg stepancheg force-pushed the stepancheg:stream-repeat branch from e1371d7 to fb4ef0d Jan 3, 2017

@stepancheg

This comment has been minimized.

Copy link
Contributor Author

stepancheg commented Jan 3, 2017

Renamed RepeatStream to Repeat.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 3, 2017

@Stebalien perhaps, but let's not discuss that here.

@stepancheg thanks!

@alexcrichton alexcrichton merged commit d90e066 into rust-lang-nursery:master Jan 3, 2017

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

stepancheg added a commit to stepancheg/grpc-rust that referenced this pull request Jan 21, 2017

Update to latest futures-rs
* sender no longer needs to be mutable: rust-lang-nursery/futures-rs#327
* use stream::repeat from futures-rs: rust-lang-nursery/futures-rs#326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.