pub fn unescape(s: &str) -> String { if !s.contains('\\') { return s.to_string(); } let mut out = String::with_capacity(s.len()); let mut it = s.chars(); while let Some(c) = it.next() { if c != '\\' { out.push(c); continue; } match it.next() { Some('n') => out.push('\n'), Some('r') => out.push('\r'), Some('t') => out.push('\t'), Some('u') => { let hex: String = it.by_ref().take(4).collect(); if let Some(ch) = u32::from_str_radix(&hex, 16).ok().and_then(char::from_u32) { out.push(ch); } } Some(other) => out.push(other), None => break, } } out }