Skip to content

Commit 2bfe619

Browse files
refactor: simplify string repeat in guess_indentor (#8753)
**Description:** Replaces a manual `String::with_capacity` + loop with `" ".repeat()` in `guess_indentor` for cleaner, more idiomatic Rust.
1 parent 1de3f79 commit 2bfe619

File tree

1 file changed

+1
-5
lines changed
  • crates/string_wizard/src/magic_string

1 file changed

+1
-5
lines changed

crates/string_wizard/src/magic_string/indent.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ pub fn guess_indentor(source: &str) -> Option<String> {
4141
.min()
4242
.unwrap_or(0);
4343

44-
let mut indent_str = String::with_capacity(min_space_count);
45-
for _ in 0..min_space_count {
46-
indent_str.push(' ');
47-
}
48-
Some(indent_str)
44+
Some(" ".repeat(min_space_count))
4945
}
5046

5147
#[derive(Debug, Default)]

0 commit comments

Comments
 (0)