]> git.lizzy.rs Git - rust.git/commit
Add method str::repeat(self, usize) -> String
authorUlrik Sverdrup <bluss@users.noreply.github.com>
Sat, 24 Sep 2016 17:35:24 +0000 (19:35 +0200)
committerUlrik Sverdrup <bluss@users.noreply.github.com>
Mon, 10 Oct 2016 22:24:23 +0000 (00:24 +0200)
commit2b7222d3ececbdc9840a3d7bd34f6cca905b80ad
treeee5718d6f3fd2b88569d602a733d8d7d96001a74
parenta5dbf8a0f8843c5466c3866cc2a288c0ef7051d2
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.
src/libcollections/str.rs
src/libcollectionstest/lib.rs
src/libcollectionstest/str.rs