mirror of
https://github.com/nushell/nushell.git
synced 2024-12-13 10:41:52 +01:00
15 lines
307 B
Rust
15 lines
307 B
Rust
|
pub fn escape_quote_string(input: &str) -> String {
|
||
|
let mut output = String::with_capacity(input.len() + 2);
|
||
|
output.push('"');
|
||
|
|
||
|
for c in input.chars() {
|
||
|
if c == '"' || c == '\\' {
|
||
|
output.push('\\');
|
||
|
}
|
||
|
output.push(c);
|
||
|
}
|
||
|
|
||
|
output.push('"');
|
||
|
output
|
||
|
}
|