-
Notifications
You must be signed in to change notification settings - Fork 448
Add conformances to LazySequenceProtocol and LazyCollectionProtocol #47
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
Conversation
Probably should add (conditional) |
Huh, I was under the impression that The
so we indeed can't assume that |
I was surprised too when I re-read the |
I've just been through all the types and the only one that can be conformed to I have renamed the |
I realised that I was only looking at types that already conform to
|
|
It would still be beneficial for them to have the conformance though? The following works if extension LazySequenceProtocol {
func someLazyOnlyFunction() {}
}
let first = (1...).prefix(10).lazy
let second = (20...).lazy
chain(first, second).someLazyOnlyFunction() |
In theory nothing is stopping them from conforming, but the laziness of sequences is only expected to propagate through method calls (lazy chaining) and not through the parameters of functions like It could also be ambiguous whether both input sequences would need to be lazy for the laziness to propagate, or that just one is enough. Always propagating the laziness of the |
Thanks for explaining that @timvermeulen. In that case I believe this PR is ready to go. 🙂 |
Looks great — thanks so much for noticing and fixing this, @danielctull! |
This fixes an omission in
Intersperse
where it doesn't currently conform toLazySequenceProtocol
when the base sequence also conforms toLazySequenceProtocol
.Checklist