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*’.
Auto Trait Implementations§
impl<'a> Freeze for Words<'a>
impl<'a> RefUnwindSafe for Words<'a>
impl<'a> Send for Words<'a>
impl<'a> Sync for Words<'a>
impl<'a> Unpin for Words<'a>
impl<'a> UnwindSafe for Words<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more