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.
assert_eq!(
vec!["case", "conversion", "library"],
Pattern::Lowercase.mutate(&["Case", "CONVERSION", "library"])
);
Uppercase
Uppercase patterns make all words uppercase.
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.
assert_eq!(
vec!["Case", "Conversion", "Library"],
Pattern::Capital.mutate(&["Case", "CONVERSION", "library"])
);
Sentence
Capital patterns make the first word capitalized and the remaining lowercase.
assert_eq!(
vec!["Case", "conversion", "library"],
Pattern::Sentence.mutate(&["Case", "CONVERSION", "library"])
);
Camel
Camel patterns make the first word lowercase and the remaining capitalized.
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.
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.
assert_eq!(
vec!["cASE", "cONVERSION", "lIBRARY"],
Pattern::Toggle.mutate(&["Case", "CONVERSION", "library"])
);