Skip to main content

StringUtil

Trait StringUtil 

Source
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§

Source

fn is_quoted(&self) -> bool

is_quoted returns true if the string is quoted.

Source

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.

Source

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.

Source

fn url_to_nodes(&self) -> Vec<&str>

url_to_nodes returns a vector of nodes from a URL string.

Source

fn ensure_prefix(&self, prefix: &str) -> String

ensure_prefix ensures that the string has the prefix.

Source

fn ensure_suffix(&self, suffix: &str) -> String

ensure_suffix ensures that the string has the suffix.

Source

fn drop_prefix(&self, prefix: &str) -> String

drop_prefix drops the prefix from the string.

Source

fn drop_suffix(&self, suffix: &str) -> String

drop_suffix drops the suffix from the string.

Source

fn join_path_segment(&self, segment: &str) -> String

join_path_segment joins a path segment to the URL.

Source

fn join_path_segments(&self, segments: Vec<&str>) -> String

join_path_segments joins multiple path segments to the URL.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl StringUtil for str

Source§

fn is_quoted(&self) -> bool

Source§

fn unquote(&self, unescape: bool, quote_set: Option<&HashSet<char>>) -> String

Source§

fn substring(&self, start: i64, end: i64) -> &str

Source§

fn url_to_nodes(&self) -> Vec<&str>

Source§

fn ensure_prefix(&self, prefix: &str) -> String

Source§

fn ensure_suffix(&self, suffix: &str) -> String

Source§

fn drop_prefix(&self, prefix: &str) -> String

Source§

fn drop_suffix(&self, suffix: &str) -> String

Source§

fn join_path_segment(&self, segment: &str) -> String

Source§

fn join_path_segments(&self, segments: Vec<&str>) -> String

Implementors§