Enum Pattern

enum Pattern

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

impl Pattern

fn mutate(self: &Self, words: &[&str]) -> Vec<String>

Generates a vector of new Strings in the right pattern given the input strings.

# use convert_case::Pattern;
assert_eq!(
    vec!["crack", "the", "skye"],
    Pattern::Lowercase.mutate(&vec!["CRACK", "the", "Skye"]),
)

impl Clone for Pattern

fn clone(self: &Self) -> Pattern

impl Copy for Pattern

impl Debug for Pattern

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for Pattern

impl Freeze for Pattern

impl PartialEq for Pattern

fn eq(self: &Self, other: &Pattern) -> bool

impl RefUnwindSafe for Pattern

impl Send for Pattern

impl StructuralPartialEq for Pattern

impl Sync for Pattern

impl Unpin for Pattern

impl UnsafeUnpin for Pattern

impl UnwindSafe for Pattern

impl<T> Any for Pattern

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Pattern

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Pattern

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Pattern

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Pattern

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Pattern

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Pattern

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Pattern

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Pattern

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>