mirror of
https://github.com/nushell/nushell
synced 2025-01-05 01:39:02 +00: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
|
||
|
}
|