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"])
);
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,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
Lowercase
: 0 bytesUppercase
: 0 bytesCapital
: 0 bytesSentence
: 0 bytesCamel
: 0 bytesAlternating
: 0 bytesToggle
: 0 bytes