Skip to content

Commit 9748ba7

Browse files
Use format! instead of write_fmt/format_args
1 parent 6b6cd47 commit 9748ba7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

html5ever/src/util/str.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@
1010
use std::fmt;
1111

1212
pub fn to_escaped_string<T: fmt::Debug>(x: &T) -> String {
13-
use std::fmt::Write;
14-
1513
// FIXME: don't allocate twice
16-
let mut buf = String::new();
17-
let _ = buf.write_fmt(format_args!("{:?}", x));
18-
buf.shrink_to_fit();
19-
buf.chars().flat_map(|c| c.escape_default()).collect()
14+
let string = format!("{:?}", x);
15+
string.chars().flat_map(|c| c.escape_default()).collect()
2016
}
2117

2218
/// If `c` is an ASCII letter, return the corresponding lowercase

0 commit comments

Comments
 (0)