From 1065b44eef73f7d632f28e54a7479c91694cd6c9 Mon Sep 17 00:00:00 2001 From: Zeeshan Ali Date: Thu, 6 Oct 2022 21:59:15 +0200 Subject: [PATCH] Use a char instead of single-char string Fixes a clippy warning: ``` warning: single-character string constant used as pattern --> src/utils.rs:11:46 | 11 | escaped = Cow::Owned(escaped.replace("\"", "\\\"")); | ^^^^ help: try using a `char` instead: `'\"'` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern ``` --- examples/parse_command.rs | 2 +- src/utils.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/parse_command.rs b/examples/parse_command.rs index 91e7e77..ed389d1 100644 --- a/examples/parse_command.rs +++ b/examples/parse_command.rs @@ -37,7 +37,7 @@ fn main() -> std::io::Result<()> { let mut line = String::new(); std::io::stdin().read_line(&mut line)?; - line.replace("\n", "\r\n") + line.replace('\n', "\r\n") }; if line.trim() == "exit" { diff --git a/src/utils.rs b/src/utils.rs index 23cf475..0abe161 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -4,11 +4,11 @@ pub(crate) fn escape_quoted(unescaped: &str) -> Cow { let mut escaped = Cow::Borrowed(unescaped); if escaped.contains('\\') { - escaped = Cow::Owned(escaped.replace("\\", "\\\\")); + escaped = Cow::Owned(escaped.replace('\\', "\\\\")); } if escaped.contains('\"') { - escaped = Cow::Owned(escaped.replace("\"", "\\\"")); + escaped = Cow::Owned(escaped.replace('\"', "\\\"")); } escaped