(s: &str)
| 162 | } |
| 163 | |
| 164 | fn unescape_string(s: &str) -> String { |
| 165 | let mut result = String::with_capacity(s.len()); |
| 166 | let mut chars = s.chars().peekable(); |
| 167 | |
| 168 | while let Some(ch) = chars.next() { |
| 169 | if ch == '\\' { |
| 170 | match chars.next() { |
| 171 | Some('n') => result.push('\n'), |
| 172 | Some('t') => result.push('\t'), |
| 173 | Some('r') => result.push('\r'), |
| 174 | Some('\\') => result.push('\\'), |
| 175 | Some('"') => result.push('"'), |
| 176 | Some('\'') => result.push('\''), |
| 177 | Some(c) => { |
| 178 | result.push('\\'); |
| 179 | result.push(c); |
| 180 | } |
| 181 | None => result.push('\\'), |
| 182 | } |
| 183 | } else { |
| 184 | result.push(ch); |
| 185 | } |
| 186 | } |
| 187 | result |
| 188 | } |
no test coverage detected