-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add core::repeat(int, fn()) function #1703
Comments
Where would be the best place to put this function? An existing file in libcore/? A "repeat.rs" file in libcore? or a more general "iterator.rs" file in libcore? |
There isn't an existing place that makes sense. I was thinking of just putting it into core.rs, but that does pull it into the global scope. I hate to dump it into something as generic as util.rs because nobody will ever find it. |
making an "iter.rs" or "iterator.rs" might make a bit more sense...though "import core::iter::repeat" might be a little word-y. |
If you are going to go that route then please have a look at the iterator library nmatsakis is working on and which he intends to merge into core or std: https://github.com/nikomatsakis/rust-iter Repeat doesn't strictly have anything to do with an iterator type, but it clearly has to do with iteration. Maybe we can get @nikomatsakis's opinion |
I could add it to the iter library, I suppose! As an alternative, what about allowing block parameters to be named "_", meaning "I really don't use this." Then you could write:
which seems marginally nicer than |
I do think being able to write |
I sent @nikomatsakis a pull request for the repeat function. |
@nikomatsakis: When do you plan to integrate your "iter" module in libcore? The module "str" has has some duplicate functions doing basically the same thing, differing only in either "returning" a list of strings or an iterator. Having |
I plan to merge it today in some form.null |
That would be awesome. |
This is done. |
…ffen Invalid null usage v2 This is continuation of rust-lang#6192 after inactivity. I plan to move paths into the compiler as diagnostic items after this is merged. fixes rust-lang#1703 changelog: none
Sometimes you just want to do something some number of times. There's no real concise way to express that right now.
The text was updated successfully, but these errors were encountered: