1 2 3 4 5 6 7 8 9 10 11 12 13 14
pub fn escape_text(text: &str) -> String { text .chars() .map(|c| match c { '<' => format!("<"), '>' => format!(">"), '"' => format!("""), '\'' => format!("'"), '&' => format!("&"), _ => format!("{}", c), }) .collect() }