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
```
This commit is contained in:
Zeeshan Ali 2022-10-06 21:59:15 +02:00 committed by Damian Poddebniak
parent 7fa3ffdd1d
commit 1065b44eef
2 changed files with 3 additions and 3 deletions

View File

@ -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" {

View File

@ -4,11 +4,11 @@ pub(crate) fn escape_quoted(unescaped: &str) -> Cow<str> {
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