Skip to content

Commit 4da0da9

Browse files
committed
use more efficient code to generate repeated string
see https://rust.godbolt.org/z/z9vrFP for comparison
1 parent b4f1769 commit 4da0da9

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(n as usize);
158158
format!("r{0}\"{1}\"{0}", term, lit_content.as_str())
159159
} else {
160160
format!("\"{}\"", lit_content.as_str())

0 commit comments

Comments
 (0)