MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / escape_str

Function escape_str

src/text_input.rs:1853–1865  ·  view source on GitHub ↗

Escape all styling-significant characters in a string.

(s: &str)

Source from the content-addressed store, hash-verified

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 ///

Callers 2

insert_text_styledMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected