push_str
with single-character string literal "\n"
, use push
with a character literal instead303 tok = &mut program[ip + 1];
304 if !matches!(tok.kind, FmtTokenKind::Token(TokenType::Keyword)) {
305 tok = &mut program[ip];
306 tok.postfix.push_str("\n");307 }
308 }
309 }
Using .insert_str()
or .push_str()
with a single-character string literal is
less clear than .insert()
or .push()
.
To improve readability, prefer .insert()
or .push()
when inserting or
pushing a single character to a String
.
let mut s = "Hello, world";
s.push_str("!");
let mut s = "Hello, world";
s.push('!');