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

RepeatCall shouldn't implement DoubleEndedIterator #86

Closed
Stebalien opened this issue Dec 30, 2015 · 8 comments
Closed

RepeatCall shouldn't implement DoubleEndedIterator #86

Stebalien opened this issue Dec 30, 2015 · 8 comments

Comments

@Stebalien
Copy link
Contributor

For example, the following iterator is definitely not reservable:

RepeatCall::new({
    let mut counter = 0;
    move || {
        counter += 1;
        counter
    }
});
@bluss bluss mentioned this issue Dec 30, 2015
14 tasks
@bluss
Copy link
Member

bluss commented Dec 30, 2015

I guess you're right about that, most implementations do not make sense as double ended. You can of course run into this problem in other places, like in a regular .iter().map() too. I'm not sure what the final decision will be. After all, .map() is double ended.

@Stebalien
Copy link
Contributor Author

That's... odd. I've submitted a bug to discuss it (rust-lang/rust#30632). It kind of makes sense because map (and filter) are generally pure functions but this behavior should, at least, be noted.

However, this case is pretty clear; RepeatCall always produces an infinite sequence and infinite sequences only have one end.

@bluss
Copy link
Member

bluss commented Dec 30, 2015

I disagree actually, infinite sequences can have two ends (For example .cycle()). Maybe cycle is a bad argument, since I wrote it 😄

@bluss
Copy link
Member

bluss commented Dec 30, 2015

Oh no, cycle is not double ended! My evil plans,... Ok I guess I managed to scare you there by mistake.

@bluss
Copy link
Member

bluss commented Dec 30, 2015

On the whole, sideeffectful iterators can always cause trouble like this. I'm leaning towards wontfixing this bug for this reason, it has use cases where double endedness is useful.

@Stebalien
Copy link
Contributor Author

Infinite sequences have one end.

-- ZFC

Yes, some sequences can go backwards from the starting point but that's not double ended, it's no-ended (doubly infinite).

@bluss
Copy link
Member

bluss commented Feb 27, 2016

I thought this issue could stay open until we make a decision (0.5 is next breaking change opportunity).

Currently I lean WONTFIX.

@bluss
Copy link
Member

bluss commented Sep 22, 2016

In a crazy turn of events, I'm removing the DEI implementation in 0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants