Escape all styling-significant characters in a string.
(s: &str)
| 1851 | |
| 1852 | /// Escape all styling-significant characters in a string. |
| 1853 | pub fn escape_str(s: &str) -> String { |
| 1854 | let mut result = String::with_capacity(s.len()); |
| 1855 | for ch in s.chars() { |
| 1856 | match ch { |
| 1857 | '{' | '}' | '|' | '\\' => { |
| 1858 | result.push('\\'); |
| 1859 | result.push(ch); |
| 1860 | } |
| 1861 | _ => result.push(ch), |
| 1862 | } |
| 1863 | } |
| 1864 | result |
| 1865 | } |
| 1866 | |
| 1867 | /// Convert a visual (display) cursor position to a raw char position. |
| 1868 | /// |
no outgoing calls
no test coverage detected