replacen
, use a char
instead218 if err {
219 line.push_str(&inst.postfix.replace("\n", ""));
220 } else {
221 line.push_str(&inst.postfix.replacen("\n", "", 1));222 }
223 }
224 lines.push(line.trim_end_matches(' ').to_owned());
replacen
, use a char
instead201 if err {
202 line.push_str(&inst.prefix.replace("\n", ""));
203 } else {
204 line.push_str(&inst.prefix.replacen("\n", "", 1));205 }
206 if line.trim_matches('\n').len() == 0
207 && !matches!(
replace
, use a char
instead216 line.push_str(&inst.value);
217 line.push_str(&inst.postcolor);
218 if err {
219 line.push_str(&inst.postfix.replace("\n", ""));220 } else {
221 line.push_str(&inst.postfix.replacen("\n", "", 1));
222 }
replace
, use a char
instead199 }
200 }
201 if err {
202 line.push_str(&inst.prefix.replace("\n", ""));203 } else {
204 line.push_str(&inst.prefix.replacen("\n", "", 1));
205 }
replace
, use a char
instead297 ld_cmd.args(&[&obj_out_path_str, "-o", &exe_out_path_str]);
298 log::log(
299 LogLevel::Cmd,
300 format!("{:?}", ld_cmd).replace("\"", ""),301 opt.debug,
302 );
303 let ld = ld_cmd
Certain str
functions, such as .split()
and .find()
work on patterns that
accept both string literals as well as characters. When using such functions,
prefer char
s over single-character string literals as they are more
performant.
Replace the single-character string literal with a char
.
let x = "hello, world";
x.find("o"); // single-character str
let x = "hello, world";
x.find('o'); // use a char instead