Uh oh!
There was an error while loading. Please reload this page.
Add method str::repeat(self, usize) -> String - #36699
Conversation
rust-highfive
commented
Sep 24, 2016
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
bluss
commented
Sep 24, 2016
This method is called |
frewsxcv
commented
Sep 24, 2016
|
bluss
commented
Sep 24, 2016
Thanks. Fixed by amending. Yes I'm letting the bots do the compiling for me. |
pmarcelll
commented
Sep 24, 2016
I have an interesting idea, would it make sense to add a |
bluss
commented
Sep 24, 2016
@pmarcelll That sounds just like the existing |
pmarcelll
commented
Sep 24, 2016
Oh, I knew about |
alexcrichton
commented
Sep 26, 2016
Looks reasonable to me! I'd also be fine extending iterators/collections with more methods like this, but in isolation cc @rust-lang/libs |
alexcrichton
commented
Oct 3, 2016
Let's see if this works... @rfcbot disposition merge Only thing I see missing is a tracking issue, but we can fill that in when it's agreed to land. |
alexcrichton
commented
Oct 3, 2016
@rfcbot fcp merge |
FCP proposed with disposition to merge. Review requested from: No concerns currently listed. |
aturon
commented
Oct 4, 2016
I'm fine with this convenience (though I feel like we explicitly cut away some things like this on the road to 1.0). |
rfcbot
commented
Oct 10, 2016
All relevant subteam members have reviewed. No concerns remain. |
It is relatively simple to repeat a string n times: `(0..n).map(|_| s).collect::<String>()`. It becomes slightly more complicated to do it “right” (sizing the allocation up front), which warrants a method that does it for us. This method is useful in writing testcases, or when generating text. `format!()` can be used to repeat single characters, but not repeating strings like this.
bluss
commented
Oct 10, 2016
Amended the commit to point to tracking issue #37079 |
alexcrichton
commented
Oct 10, 2016
@bors: r+ Thanks! |
bors
commented
Oct 10, 2016
📌 Commit 2b7222d has been approved by |
bluss
commented
Oct 10, 2016
@bors rollup |
Add method str::repeat(self, usize) -> String It is relatively simple to repeat a string n times: `(0..n).map(|_| s).collect::<String>()`. It becomes slightly more complicated to do it “right” (sizing the allocation up front), which warrants a method that does it for us. This method is useful in writing testcases, or when generating text. `format!()` can be used to repeat single characters, but not repeating strings like this.
rfcbot
commented
Oct 17, 2016
It has been one week since all blocks to the FCP were resolved. |
It is relatively simple to repeat a string n times:
(0..n).map(|_| s).collect::<String>(). It becomes slightly morecomplicated to do it “right” (sizing the allocation up front), which
warrants a method that does it for us.
This method is useful in writing testcases, or when generating text.
format!()can be used to repeat single characters, but not repeatingstrings like this.