-
Notifications
You must be signed in to change notification settings - Fork 284
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
Added range for MongoCursor #172
Added range for MongoCursor #172
Conversation
Neat, always had that in mind but never had the immediate need to implement it. One question, though - it seems to me that the range interface would fit nicely into |
It was my first naive approach but then second opApply overload functionality is lost : foreach(key, value; cursor). |
Can't we just keep the second opApply in addition to the range interface? |
Tried this too, got compilation error about not being able to select foreach signature. Was not in mood to get deep into specs so reverted to this solution. There is one advantage of keeping range separate though - usual phobos approach of separating containers from ranges. I.e. later we may change the implementation so that MongoCursor.range iteration won't consume items from inner struct and change it to ForwardRange. |
But since MongoCursor itself consumes items during iteration (which surely is a good default regarding efficiency), it's more a range/range separation instead of a container/range. If a container/multiple iteration is needed, it think It's just that only |
@s-ludwig Anyway, I am perfectly fine with changing this back to MongoCursor as a range - just a bit busy to find out right now. Let me know if you will be first one to find out. |
But that section is just about I'm also still busy with other things, but should have some time later today. I'll post as soon as I have something. |
Hah, that is what you get when start coding 12h a day :) |
Okay... it seems that once there is any Do you mind if I just commit my changes and close the pull? Seems to be the fastest way. |
Sure, please do. May be worth referencing commit hash in comment here for random wanderers. |
…172. The range interface is added directly to MongoCursor in the version instead of introducing an extra range type. Original pull by Михаил Страшун (Dicebot).
One of enhancement I have long wanted - working with MongoCursor with InputRange interface. Allows for more functional way to process database data into final output with all std.algorithm & friends help.
Motivating example from tests: