fn unescape()

in crates/concrete-syntax/src/models/concrete_syntax/parser.rs [74:98]


fn unescape(src: &str) -> String {
  let mut out = String::with_capacity(src.len());
  let mut chars = src.chars();
  while let Some(c) = chars.next() {
    if c == '\\' {
      match chars.next() {
        Some('"') => out.push('"'),
        Some('\\') => out.push('\\'),
        Some('n') => out.push('\n'),
        Some('t') => out.push('\t'),
        Some('/') => out.push('/'),
        Some('@') => out.push('@'),
        Some(':') => out.push(':'),
        Some(other) => {
          out.push('\\');
          out.push(other);
        }
        None => break, // trailing back-slash
      }
    } else {
      out.push(c);
    }
  }
  out
}