pub enum Pattern {
Lowercase,
Uppercase,
Capital,
Sentence,
Camel,
Alternating,
Toggle,
}Expand description
A pattern is how a set of words is mutated before joining with a delimeter.
The Random and PseudoRandom patterns are used for their respective cases
and are only available in the “random” feature.
Variants§
Lowercase
Lowercase patterns make all words lowercase.
use convert_case::Pattern;
assert_eq!(
vec!["case", "conversion", "library"],
Pattern::Lowercase.mutate(&["Case", "CONVERSION", "library"])
);Uppercase
Uppercase patterns make all words uppercase.
use convert_case::Pattern;
assert_eq!(
vec!["CASE", "CONVERSION", "LIBRARY"],
Pattern::Uppercase.mutate(&["Case", "CONVERSION", "library"])
);Capital
Capital patterns makes the first letter of each word uppercase and the remaining letters of each word lowercase.
use convert_case::Pattern;
assert_eq!(
vec!["Case", "Conversion", "Library"],
Pattern::Capital.mutate(&["Case", "CONVERSION", "library"])
);Sentence
Capital patterns make the first word capitalized and the remaining lowercase.
use convert_case::Pattern;
assert_eq!(
vec!["Case", "conversion", "library"],
Pattern::Sentence.mutate(&["Case", "CONVERSION", "library"])
);Camel
Camel patterns make the first word lowercase and the remaining capitalized.
use convert_case::Pattern;
assert_eq!(
vec!["case", "Conversion", "Library"],
Pattern::Camel.mutate(&["Case", "CONVERSION", "library"])
);Alternating
Alternating patterns make each letter of each word alternate between lowercase and uppercase. They alternate across words, which means the last letter of one word and the first letter of the next will not be the same letter casing.
use convert_case::Pattern;
assert_eq!(
vec!["cAsE", "cOnVeRsIoN", "lIbRaRy"],
Pattern::Alternating.mutate(&["Case", "CONVERSION", "library"])
);
assert_eq!(
vec!["aNoThEr", "ExAmPlE"],
Pattern::Alternating.mutate(&["Another", "Example"]),
);Toggle
Toggle patterns have the first letter of each word uppercase and the remaining letters of each word uppercase.
use convert_case::Pattern;
assert_eq!(
vec!["cASE", "cONVERSION", "lIBRARY"],
Pattern::Toggle.mutate(&["Case", "CONVERSION", "library"])
);Implementations§
Trait Implementations§
impl Copy for Pattern
impl Eq for Pattern
impl StructuralPartialEq for Pattern
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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