pub struct Words<'a> { /* private fields */ }
Expand description
Sequence of words of some original string.
Divides the case style “enforcement” into two steps:
- Split the original string into words.
- Capitalise and concatenate the words into a new string.
Implementations§
source§impl<'a> Words<'a>
impl<'a> Words<'a>
sourcepub fn with_separator(s: &'a str, sep: &Regex) -> Words<'a>
pub fn with_separator(s: &'a str, sep: &Regex) -> Words<'a>
Creates a new Words
of the string slice using the separator regex
to split it.
sourcepub fn camel(&self) -> String
pub fn camel(&self) -> String
Returns the words capitalised and concatenated like camelCase
as a new String
.
sourcepub fn pascal(&self) -> String
pub fn pascal(&self) -> String
Returns the words capitalised and concatenated like PascalCase
as a new String
.
sourcepub fn kebab(&self) -> String
pub fn kebab(&self) -> String
Returns the words capitalised and concatenated like kebab-case
as a new String
.
sourcepub fn screaming_kebab(&self) -> String
pub fn screaming_kebab(&self) -> String
Returns the words capitalised and concatenated
like SCREAMING-KEBAB-CASE
as a new String
.
sourcepub fn lower(&self) -> String
pub fn lower(&self) -> String
Returns the words capitalised and concatenated like lower case
as a new String
.
sourcepub fn upper(&self) -> String
pub fn upper(&self) -> String
Returns the words capitalised and concatenated like UPPER CASE
as a new String
.
sourcepub fn snake(&self) -> String
pub fn snake(&self) -> String
Returns the words capitalised and concatenated like snake_case
as a new String
.
sourcepub fn screaming_snake(&self) -> String
pub fn screaming_snake(&self) -> String
Returns the words capitalised and concatenated
like SCREAMING_SNAKE_CASE
as a new String
.
sourcepub fn title(&self) -> String
pub fn title(&self) -> String
Returns the words capitalised and concatenated like Title Case
as a new String
.
Trait Implementations§
source§impl<'a> From<&'a str> for Words<'a>
impl<'a> From<&'a str> for Words<'a>
source§fn from(s: &'a str) -> Self
fn from(s: &'a str) -> Self
Creates a new Words
for the string slice.
The string is split into words by the following algorithm:
- Trim the string.
- If the string contains whitespace, then split it by whitespace.
- If the string contains hyphens ‘
-
’ or underscores ‘_
’, then split it by whichever of them is more frequent. - Split the string by case changes: ‘
*|Az
’ and ‘z|A*
’.