We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2b6787c commit d072e8dCopy full SHA for d072e8d
lib.rs
@@ -637,11 +637,15 @@ fn escape_string(string: &str) -> String {
637
// In quoted RC strings, double-quotes are escaped by using two
638
// consecutive double-quotes. Other characters are escaped in the
639
// usual C way using backslashes.
640
- if chr == '"' {
641
- escaped.push_str("\"\"");
642
- } else {
643
- escaped.extend(chr.escape_default());
644
- }
+ match chr {
+ '"' => escaped.push_str("\"\""),
+ '\'' => escaped.push_str("\\'"),
+ '\\' => escaped.push_str("\\\\"),
+ '\n' => escaped.push_str("\\n"),
645
+ '\t' => escaped.push_str("\\t"),
646
+ '\r' => escaped.push_str("\\r"),
647
+ _ => escaped.push(chr),
648
+ };
649
}
650
escaped
651
0 commit comments