Skip to content

Commit b452400

Browse files
authored
Rollup merge of #4830 - lzutao:str-repeat, r=flip1995
use more efficient code to generate repeated string see https://rust.godbolt.org/z/z9vrFP for comparison changelog: none
2 parents ae69bc4 + d229d91 commit b452400

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clippy_lints/src/strings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
154154
if let LitKind::Str(ref lit_content, style) = lit.node {
155155
let callsite = snippet(cx, args[0].span.source_callsite(), r#""foo""#);
156156
let expanded = if let StrStyle::Raw(n) = style {
157-
let term = (0..n).map(|_| '#').collect::<String>();
157+
let term = "#".repeat(usize::from(n));
158158
format!("r{0}\"{1}\"{0}", term, lit_content.as_str())
159159
} else {
160160
format!("\"{}\"", lit_content.as_str())

0 commit comments

Comments
 (0)