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:
parent
7fa3ffdd1d
commit
1065b44eef
|
@ -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" {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue