pub trait StrTools: Sealed {
// Required methods
fn sub_nearest(&self, range: impl Range) -> &str;
fn capitalise(&self) -> Cow<'_, str>;
fn decapitalise(&self) -> Cow<'_, str>;
}Available on crate feature
string only.Expand description
The main StrTools extension trait.
Required Methods§
Sourcefn sub_nearest(&self, range: impl Range) -> &str
fn sub_nearest(&self, range: impl Range) -> &str
A substring method which truncates strings at the nearest UTF-8 code rather than panicking.
§Panics
This function still panics if the given range is out of bounds. It however does not panic if the passed range falls withing a UTF-8 code.
Sourcefn capitalise(&self) -> Cow<'_, str>
fn capitalise(&self) -> Cow<'_, str>
A string capitalize function which operates on UTF-8 strings.
Sourcefn decapitalise(&self) -> Cow<'_, str>
fn decapitalise(&self) -> Cow<'_, str>
A string decapitalize function which operates on UTF-8 strings. This essentially does the inverse of the capitalise function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".