pub trait StringUtil {
// Required methods
fn is_quoted(&self) -> bool;
fn substring(&self, start: i64, end: i64) -> &str;
fn unquote(
&self,
unescape: bool,
quote_set: Option<&HashSet<char>>,
) -> String;
fn url_to_nodes(&self) -> Vec<&str>;
fn ensure_prefix(&self, prefix: &str) -> String;
fn ensure_suffix(&self, suffix: &str) -> String;
fn drop_prefix(&self, prefix: &str) -> String;
fn drop_suffix(&self, suffix: &str) -> String;
fn join_path_segment(&self, segment: &str) -> String;
fn join_path_segments(&self, segments: Vec<&str>) -> String;
}
Expand description
StringUtil provides utility methods for string manipulation.
Required Methods§
Sourcefn substring(&self, start: i64, end: i64) -> &str
fn substring(&self, start: i64, end: i64) -> &str
substring returns a substring of the string. The start and end parameters can be negative. If start is negative, it is treated as len(self) + start. If end is negative, it is treated as len(self) + end.
Sourcefn unquote(&self, unescape: bool, quote_set: Option<&HashSet<char>>) -> String
fn unquote(&self, unescape: bool, quote_set: Option<&HashSet<char>>) -> String
unquote removes the quotes from the string. If unescape is true, it will unescape the string. If quote_set is provided, it will only unquote if the quote character is in the set.
Sourcefn url_to_nodes(&self) -> Vec<&str>
fn url_to_nodes(&self) -> Vec<&str>
url_to_nodes returns a vector of nodes from a URL string.
Sourcefn ensure_prefix(&self, prefix: &str) -> String
fn ensure_prefix(&self, prefix: &str) -> String
ensure_prefix ensures that the string has the prefix.
Sourcefn ensure_suffix(&self, suffix: &str) -> String
fn ensure_suffix(&self, suffix: &str) -> String
ensure_suffix ensures that the string has the suffix.
Sourcefn drop_prefix(&self, prefix: &str) -> String
fn drop_prefix(&self, prefix: &str) -> String
drop_prefix drops the prefix from the string.
Sourcefn drop_suffix(&self, suffix: &str) -> String
fn drop_suffix(&self, suffix: &str) -> String
drop_suffix drops the suffix from the string.
Sourcefn join_path_segment(&self, segment: &str) -> String
fn join_path_segment(&self, segment: &str) -> String
join_path_segment joins a path segment to the URL.
Sourcefn join_path_segments(&self, segments: Vec<&str>) -> String
fn join_path_segments(&self, segments: Vec<&str>) -> String
join_path_segments joins multiple path segments to the URL.