We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Once repeat_n has being stabilized, it suggests to replace repeat+take with repeat_n in some simple cases.
Shorter code, less tokens for the programmer mind.
I can't think any.
#![feature(iter_repeat_n)] use std::iter; fn main() { for x in iter::repeat(10).take(3) { print!("{x} "); } println!(); }
Could be written as:
#![feature(iter_repeat_n)] use std::iter; fn main() { for x in iter::repeat_n(10, 3) { print!("{x} "); } println!(); }
The text was updated successfully, but these errors were encountered:
repeat().take()
repeat_n()
Successfully merging a pull request may close this issue.
What it does
Once repeat_n has being stabilized, it suggests to replace repeat+take with repeat_n in some simple cases.
Advantage
Shorter code, less tokens for the programmer mind.
Drawbacks
I can't think any.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: