pub trait SimpleEnclose {
Show 14 methods
// Required method
fn enclose_in_chars(
&self,
start: char,
end: char,
prefix: Option<&str>,
escape_char: Option<char>,
) -> String;
// Provided methods
fn enclose_escaped(
&self,
start: char,
end: char,
escape_char: Option<char>,
) -> String { ... }
fn enclose(&self, start: char, end: char) -> String { ... }
fn enclose_safe(&self, start: char, end: char) -> String { ... }
fn wrap_escaped(&self, opening: char, escape_char: Option<char>) -> String { ... }
fn wrap(&self, opening: char) -> String { ... }
fn wrap_safe(&self, opening: char) -> String { ... }
fn in_parentheses(&self, prefix: Option<&str>) -> String { ... }
fn parenthesize(&self) -> String { ... }
fn parenthesize_safe(&self) -> String { ... }
fn double_quotes(&self) -> String { ... }
fn single_quotes(&self) -> String { ... }
fn double_quotes_safe(&self) -> String { ... }
fn single_quotes_safe(&self) -> String { ... }
}
Expand description
Traits with extension emthods to wrap strings in bounding characters
Required Methods§
Sourcefn enclose_in_chars(
&self,
start: char,
end: char,
prefix: Option<&str>,
escape_char: Option<char>,
) -> String
fn enclose_in_chars( &self, start: char, end: char, prefix: Option<&str>, escape_char: Option<char>, ) -> String
Enclose in a start and an end character with an optional prefix before the main content but after the first character This is a common syntactical pattern in many markup and programming languages the closing character will be the same opening character The optional escape character is inserted before occurrences of the end character unless the preceding character is the escape character itself to avoid double escaping of pre-escaped strings
Provided Methods§
Sourcefn enclose_escaped(
&self,
start: char,
end: char,
escape_char: Option<char>,
) -> String
fn enclose_escaped( &self, start: char, end: char, escape_char: Option<char>, ) -> String
Enclose in a start and an end character with an optional prefix after the first character
Sourcefn enclose(&self, start: char, end: char) -> String
fn enclose(&self, start: char, end: char) -> String
Enclose in a start and an end character with an optional prefix after the first character
Sourcefn enclose_safe(&self, start: char, end: char) -> String
fn enclose_safe(&self, start: char, end: char) -> String
Enclose in a start and an end character with an optional prefix after the first character escaped where necessary with a backslash \
Sourcefn wrap_escaped(&self, opening: char, escape_char: Option<char>) -> String
fn wrap_escaped(&self, opening: char, escape_char: Option<char>) -> String
Wrap a string in a pair of characters, with the closing character matching the first character if it a parenthesis (round bracket), angle bracket, (square) bracket or curly brace. Otherwise the closing character will be the same opening character The optional escape character is inserted before occurrences of the end character unless the preceding character is the escape character itself to avoid double escaping of pre-escaped strings
Sourcefn wrap(&self, opening: char) -> String
fn wrap(&self, opening: char) -> String
wrap a string in the same opening and closing character
Sourcefn wrap_safe(&self, opening: char) -> String
fn wrap_safe(&self, opening: char) -> String
Wrap in matching characters escaped by a backslash \
Sourcefn in_parentheses(&self, prefix: Option<&str>) -> String
fn in_parentheses(&self, prefix: Option<&str>) -> String
wrap in parentheses (sound brackets) with an optional prefix before the main content
Sourcefn parenthesize(&self) -> String
fn parenthesize(&self) -> String
wrap in parentheses (sound brackets)
Sourcefn parenthesize_safe(&self) -> String
fn parenthesize_safe(&self) -> String
wrap in parentheses (sound brackets)
Sourcefn double_quotes(&self) -> String
fn double_quotes(&self) -> String
wrap in parentheses (sound brackets)
Sourcefn single_quotes(&self) -> String
fn single_quotes(&self) -> String
Wrap in single quotes
Sourcefn double_quotes_safe(&self) -> String
fn double_quotes_safe(&self) -> String
Wrap in double quotes with escaped quotes in the content
Sourcefn single_quotes_safe(&self) -> String
fn single_quotes_safe(&self) -> String
Wrap in single quotes with escaped quotes in the content
Implementations on Foreign Types§
Source§impl SimpleEnclose for str
Implement the base method for &str/String
impl SimpleEnclose for str
Implement the base method for &str/String